当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Catalog_Model_Category::setStoreId方法代码示例

本文整理汇总了PHP中Mage_Catalog_Model_Category::setStoreId方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::setStoreId方法的具体用法?PHP Mage_Catalog_Model_Category::setStoreId怎么用?PHP Mage_Catalog_Model_Category::setStoreId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Catalog_Model_Category的用法示例。


在下文中一共展示了Mage_Catalog_Model_Category::setStoreId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testSaveAction

 /**
  * @magentoDataFixture Mage/Core/_files/store.php
  * @magentoDbIsolation enabled
  * @dataProvider saveActionDataProvider
  * @param array $inputData
  * @param array $defaultAttributes
  * @param array $attributesSaved
  */
 public function testSaveAction($inputData, $defaultAttributes, $attributesSaved = array())
 {
     $store = new Mage_Core_Model_Store();
     $store->load('fixturestore', 'code');
     $storeId = $store->getId();
     $this->getRequest()->setPost($inputData);
     $this->getRequest()->setParam('store', $storeId);
     $this->getRequest()->setParam('id', 2);
     $this->dispatch('backend/admin/catalog_category/save');
     $messages = Mage::getSingleton('Mage_Backend_Model_Session')->getMessages(false)->getItemsByType(Mage_Core_Model_Message::SUCCESS);
     $this->assertNotEmpty($messages, "Could not save category");
     $this->assertEquals('The category has been saved.', current($messages)->getCode());
     $category = new Mage_Catalog_Model_Category();
     $category->setStoreId($storeId);
     $category->load(2);
     $errors = array();
     foreach ($attributesSaved as $attribute => $value) {
         $actualValue = $category->getData($attribute);
         if ($value !== $actualValue) {
             $errors[] = "value for '{$attribute}' attribute must be '{$value}', but '{$actualValue}' is found instead";
         }
     }
     foreach ($defaultAttributes as $attribute => $exists) {
         if ($exists !== $category->getExistsStoreValueFlag($attribute)) {
             if ($exists) {
                 $errors[] = "custom value for '{$attribute}' attribute is not found";
             } else {
                 $errors[] = "custom value for '{$attribute}' attribute is found, but default one must be used";
             }
         }
     }
     $this->assertEmpty($errors, "\n" . join("\n", $errors));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:41,代码来源:CategoryControllerTest.php

示例2: getCategory

 /**
  * Search category by the name from root category or specified one.
  * Create category when it doesn't exist if $createIfNotExists
  * parameter is set.
  * Search category by store-specific name if $store parameter is set.
  *
  * @param string $name
  * @param bool $createIfNotExists
  * @param Mage_Catalog_Model_Category $parent
  * @param null|Mage_Core_Model_Store $store
  *
  * @return Mage_Catalog_Model_Category|null
  */
 public function getCategory($name, $createIfNotExists = false, $parent = null, $store = null)
 {
     $store = $store instanceof Mage_Core_Model_Store ? $store : Mage::app()->getStore();
     $collection = $parent && ($parentId = $parent->getId()) ? $parent->setStoreId($store->getId())->getCollection()->addFieldToFilter('parent_id', $parentId) : Mage::getModel('catalog/category')->setStoreId($store->getId())->load($store->getRootCategoryId())->getCollection();
     $collection->addAttributeToFilter('name', $name);
     if ($collection->count()) {
         return $collection->getFirstItem();
     }
     if (!$createIfNotExists) {
         return;
     }
     if ($parent && $parent->getId()) {
         $rootCategory = $parent;
     } else {
         $collection = Mage::getModel('catalog/category')->getCollection()->addAttributeToFilter('parent_id', 1);
         if (count($collection) != 1) {
             return null;
         }
         $rootCategory = $collection->getFirstItem();
         if (!$rootCategory->getId()) {
             return null;
         }
     }
     $model = Mage::getModel('catalog/category');
     $model->setStoreId($rootCategory->getStoreId())->setData(array('name' => $name, 'is_active' => 1, 'include_in_menu' => 1))->setPath($rootCategory->getPath())->setAttributeSetId($model->getDefaultAttributeSetId());
     try {
         $model->save();
     } catch (Exception $e) {
         return null;
     }
     return $model;
 }
开发者ID:james-hickman-arc,项目名称:magento-w2p,代码行数:45,代码来源:Category.php

示例3: getRootCategory

 public function getRootCategory()
 {
     if (!$this->_rootCategory) {
         $this->_rootCategory = Mage::getModel('catalog/category');
         $this->_rootCategory->setStoreId(Mage::app()->getStore()->getId())->load(Mage::app()->getStore()->getRootCategoryId());
     }
     return $this->_rootCategory;
 }
开发者ID:bhushansonar,项目名称:electronics,代码行数:8,代码来源:Data.php

示例4: _setUrlKeyForDefaultStore

 /**
  * Write category url_key for category into default store
  *
  * @param Mage_Catalog_Model_Category $category
  * @param Mage_Core_Model_Store $store
  * @return Mage_Catalog_Model_Category
  */
 protected function _setUrlKeyForDefaultStore(Mage_Catalog_Model_Category $category, Mage_Core_Model_Store $store)
 {
     //we should save url key for default store
     $category->setStoreId(0);
     $this->_urlModel->getResource()->saveCategoryAttribute($category, 'url_key');
     //return current store to category
     $category->setStoreId($store->getId());
     return $category;
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:16,代码来源:Refresh.php

示例5: testSetGetStoreId

 public function testSetGetStoreId()
 {
     $this->assertEquals(Mage::app()->getStore()->getId(), $this->_model->getStoreId());
     $this->_model->setStoreId(1000);
     $this->assertEquals(1000, $this->_model->getStoreId());
 }
开发者ID:natxetee,项目名称:magento2,代码行数:6,代码来源:CategoryTest.php

示例6: processCategory

 /**
  * Update category url key
  *
  * @param Mage_Catalog_Model_Category $category
  * @param string $newUrlKey
  * @param int $storeId
  */
 function processCategory($category, $newUrlKey, $storeId)
 {
     $store = Mage::app()->getStore();
     Mage::app()->setCurrentStore(Mage::app()->getStore(0));
     if (!$this->isEntityProcessed(self::ENTITY_TYPE_CATEGORY, $category->getId() . '-' . $storeId) && !preg_match('~-[a-f0-9]{32}$~i', $newUrlKey)) {
         $category->setStoreId($storeId);
         $category->setUrlKey($newUrlKey . '-' . md5($category->getStoreId() . $category->getId()));
         $category->save();
         $this->_reindexCategory($category->getId());
         $category->unsetData('request_path');
         $category->unsetData('url');
         $this->markEntityProcessed(self::ENTITY_TYPE_CATEGORY, $category->getId() . '-' . $category->getStoreId());
     }
     Mage::app()->setCurrentStore($store);
 }
开发者ID:hyhoocchan,项目名称:mage-local,代码行数:22,代码来源:Migration.php


注:本文中的Mage_Catalog_Model_Category::setStoreId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。