當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Mage_Catalog_Model_Category::load方法代碼示例

本文整理匯總了PHP中Mage_Catalog_Model_Category::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP Mage_Catalog_Model_Category::load方法的具體用法?PHP Mage_Catalog_Model_Category::load怎麽用?PHP Mage_Catalog_Model_Category::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Mage_Catalog_Model_Category的用法示例。


在下文中一共展示了Mage_Catalog_Model_Category::load方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: setUp

 protected function setUp()
 {
     $this->_category = Mage::getModel('Mage_Catalog_Model_Category');
     $this->_category->load(5);
     $this->_model = Mage::getModel('Mage_Catalog_Model_Layer_Filter_Category');
     $this->_model->setData(array('layer' => Mage::getModel('Mage_Catalog_Model_Layer', array('data' => array('current_category' => $this->_category)))));
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:7,代碼來源:CategoryTest.php

示例2: setUp

 protected function setUp()
 {
     $this->_category = new Mage_Catalog_Model_Category();
     $this->_category->load(5);
     $this->_model = new Mage_Catalog_Model_Layer_Filter_Category();
     $this->_model->setData(array('layer' => new Mage_Catalog_Model_Layer(array('current_category' => $this->_category))));
 }
開發者ID:NatashaOlut,項目名稱:Mage_Test,代碼行數:7,代碼來源:Category.php

示例3: _getCategoryPath

 /**
  * Get category ids path by id
  *
  * @param int $categoryId
  * @return string
  *
  * @return void
  */
 protected function _getCategoryPath($categoryId)
 {
     if (!isset($this->_paths[$categoryId])) {
         $this->_paths[$categoryId] = $this->_categoryModel->load($categoryId)->getPath();
     }
     return $this->_paths[$categoryId];
 }
開發者ID:QiuLihua83,項目名稱:magento-enterprise-1.13.1.0,代碼行數:15,代碼來源:Redirect.php

示例4: _getProductCollection

 /**
  * Retrieve loaded category collection.
  * Variables collected from CMS markup: category_id, product_count, is_random
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $categoryID = $this->getCategoryId();
         if ($categoryID) {
             $category = new Mage_Catalog_Model_Category();
             $category->load($categoryID);
             $collection = $category->getProductCollection();
             //Sort order parameters
             $sortBy = $this->getSortBy();
             //param: sort_by
             if ($sortBy === NULL) {
                 $sortBy = 'position';
             }
             $sortDirection = $this->getSortDirection();
             //param: sort_direction
             if ($sortDirection === NULL) {
                 $sortDirection = 'ASC';
             }
             $collection->addAttributeToSort($sortBy, $sortDirection);
         } else {
             $collection = Mage::getResourceModel('catalog/product_collection');
         }
         Mage::getModel('catalog/layer')->prepareProductCollection($collection);
         if ($this->getIsRandom()) {
             $collection->getSelect()->order('rand()');
         }
         $collection->addStoreFilter();
         $productCount = $this->getProductCount() ? $this->getProductCount() : 8;
         $collection->setPage(1, $productCount)->load();
         $this->_productCollection = $collection;
     }
     return $this->_productCollection;
 }
開發者ID:klord9x,項目名稱:project-nam1,代碼行數:38,代碼來源:Featured.php

示例5: 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

示例6: testIsInRootCategoryList

 public function testIsInRootCategoryList()
 {
     $this->assertFalse($this->_model->isInRootCategoryList());
     $this->_model->unsetData();
     $this->_model->load(3);
     $this->assertTrue($this->_model->isInRootCategoryList());
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:7,代碼來源:CategoryTreeTest.php

示例7: _getProductCollection

 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $categoryID = $this->getCategoryId();
         if ($categoryID) {
             $category = new Mage_Catalog_Model_Category();
             $category->load($categoryID);
             // this is category id
             $collection = $category->getProductCollection();
         } else {
             $collection = Mage::getResourceModel('catalog/product_collection');
         }
         $todayDate = date('m/d/y');
         $tomorrow = mktime(0, 0, 0, date('m'), date('d') + 1, date('y'));
         $tomorrowDate = date('m/d/y', $tomorrow);
         Mage::getModel('catalog/layer')->prepareProductCollection($collection);
         //$collection->getSelect()->order('rand()');
         $collection->addAttributeToSort('created_at', 'desc');
         $collection->addStoreFilter();
         $collection->addAttributeToFilter('special_from_date', array('date' => true, 'to' => $todayDate))->addAttributeToFilter('special_to_date', array('or' => array(0 => array('date' => true, 'from' => $tomorrowDate), 1 => array('is' => new Zend_Db_Expr('null')))), 'left');
         $numProducts = $this->getNumProducts() ? $this->getNumProducts() : 0;
         $collection->setPage(1, $numProducts)->load();
         $this->_productCollection = $collection;
     }
     return $this->_productCollection;
 }
開發者ID:xiaoguizhidao,項目名稱:tyler-live,代碼行數:26,代碼來源:special.php

示例8: testGetProductCount

 public function testGetProductCount()
 {
     $this->_model->load(6);
     $this->assertEquals(0, $this->_model->getProductCount());
     $this->_model->setData(array());
     $this->_model->load(3);
     $this->assertEquals(1, $this->_model->getProductCount());
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:8,代碼來源:CategoryTest.php

示例9: setUp

 protected function setUp()
 {
     $category = new Mage_Catalog_Model_Category();
     $category->load(4);
     $attribute = new Mage_Catalog_Model_Entity_Attribute();
     $attribute->loadByCode('catalog_product', 'weight');
     $this->_model = new Mage_Catalog_Model_Layer_Filter_Decimal();
     $this->_model->setData(array('layer' => new Mage_Catalog_Model_Layer(array('current_category' => $category)), 'attribute_model' => $attribute));
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:9,代碼來源:DecimalTest.php

示例10: getProductIds

 public function getProductIds()
 {
     $categories = array(20, 49, 62, 72, 88, 101, 105, 114, 115);
     foreach ($categories as $cat) {
         $category = new Mage_Catalog_Model_Category();
         $category->load($cat);
         $collection = $category->getProductCollection()->addAttributeToFilter(array(array('attribute' => 'image', 'nlike' => 'no_selection'), array('attribute' => 'image', 'null' => false)))->setPageSize(4)->addAttributeToSort('created_at', 'desc');
         foreach ($collection as $product) {
             $result[] = $product->getId();
         }
     }
     return $result;
 }
開發者ID:shebin512,項目名稱:Magento_Zoff,代碼行數:13,代碼來源:Listcategories.php

示例11: _getCategory

 /**
  * Get Category from request
  *
  * @return Mage_Catalog_Model_Category
  */
 private function _getCategory()
 {
     if (!$this->_category) {
         $this->_category = Mage::getModel('Mage_Catalog_Model_Category');
         $categoryId = (int) $this->getRequest()->getParam('category', 0);
         if (!$categoryId && $this->_getUrlRewrite()->getId()) {
             $categoryId = $this->_getUrlRewrite()->getCategoryId();
         }
         if ($categoryId) {
             $this->_category->load($categoryId);
         }
     }
     return $this->_category;
 }
開發者ID:natxetee,項目名稱:magento2,代碼行數:19,代碼來源:UrlrewriteController.php

示例12: getProductsInCategory

 public function getProductsInCategory(int $catId)
 {
     $_category = Mage::getModel('catalog/category')->load($catId);
     $subs = $_category->getAllChildren(true);
     $result = array();
     foreach ($subs as $cat_id) {
         $category = new Mage_Catalog_Model_Category();
         $category->load($cat_id);
         $collection = $category->getProductCollection();
         foreach ($collection as $product) {
             $result[] = $product->getId();
         }
     }
     return $result;
 }
開發者ID:xiaoguizhidao,項目名稱:blingjewelry-prod,代碼行數:15,代碼來源:Category.php

示例13: testGetBreadcrumbPath

 /**
  * @magentoDataFixture Mage/Catalog/_files/categories.php
  */
 public function testGetBreadcrumbPath()
 {
     $category = new Mage_Catalog_Model_Category();
     $category->load(5);
     Mage::register('current_category', $category);
     try {
         $path = $this->_helper->getBreadcrumbPath();
         $this->assertInternalType('array', $path);
         $this->assertEquals(array('category3', 'category4', 'category5'), array_keys($path));
         $this->assertArrayHasKey('label', $path['category3']);
         $this->assertArrayHasKey('link', $path['category3']);
         Mage::unregister('current_category');
     } catch (Exception $e) {
         Mage::unregister('current_category');
         throw $e;
     }
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:20,代碼來源:DataTest.php

示例14: _getProductCollection

 /**
  * Retrieve loaded category collection.
  * Variables collected from CMS markup: category_id, product_count, is_random
  */
 protected function _getProductCollection()
 {
     if (is_null($this->_productCollection)) {
         $categoryID = $this->getCategoryId();
         if ($categoryID) {
             $category = new Mage_Catalog_Model_Category();
             $category->load($categoryID);
             $collection = $category->getProductCollection();
         } else {
             $collection = Mage::getResourceModel('catalog/product_collection');
         }
         Mage::getModel('catalog/layer')->prepareProductCollection($collection);
         if ($this->getIsRandom()) {
             $collection->getSelect()->order('rand()');
         }
         $collection->addStoreFilter();
         $productCount = $this->getProductCount() ? $this->getProductCount() : 8;
         $collection->setPage(1, $productCount)->load();
         $this->_productCollection = $collection;
     }
     return $this->_productCollection;
 }
開發者ID:jronatay,項目名稱:ultimo-magento-jron,代碼行數:26,代碼來源:Featured.php

示例15: testGetSetCurrentCategory

 public function testGetSetCurrentCategory()
 {
     $existingCategory = new Mage_Catalog_Model_Category();
     $existingCategory->load(5);
     /* Category object */
     $model = new Mage_Catalog_Model_Layer();
     $model->setCurrentCategory($existingCategory);
     $this->assertSame($existingCategory, $model->getCurrentCategory());
     /* Category id */
     $model = new Mage_Catalog_Model_Layer();
     $model->setCurrentCategory(3);
     $actualCategory = $model->getCurrentCategory();
     $this->assertInstanceOf('Mage_Catalog_Model_Category', $actualCategory);
     $this->assertEquals(3, $actualCategory->getId());
     $this->assertSame($actualCategory, $model->getCurrentCategory());
     /* Category in registry */
     Mage::register('current_category', $existingCategory);
     try {
         $model = new Mage_Catalog_Model_Layer();
         $this->assertSame($existingCategory, $model->getCurrentCategory());
         Mage::unregister('current_category');
         $this->assertSame($existingCategory, $model->getCurrentCategory());
     } catch (Exception $e) {
         Mage::unregister('current_category');
         throw $e;
     }
     try {
         $model = new Mage_Catalog_Model_Layer();
         $model->setCurrentCategory(new Varien_Object());
         $this->fail('Assign category of invalid class.');
     } catch (Mage_Core_Exception $e) {
     }
     try {
         $model = new Mage_Catalog_Model_Layer();
         $model->setCurrentCategory(new Mage_Catalog_Model_Category());
         $this->fail('Assign category with invalid id.');
     } catch (Mage_Core_Exception $e) {
     }
 }
開發者ID:nemphys,項目名稱:magento2,代碼行數:39,代碼來源:LayerTest.php


注:本文中的Mage_Catalog_Model_Category::load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。