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


PHP Category::load方法代码示例

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


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

示例1: setUp

 protected function setUp()
 {
     $this->_category = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Category');
     $this->_category->load(5);
     $layer = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Layer\\Category', ['data' => ['current_category' => $this->_category]]);
     $this->_model = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create('Magento\\Catalog\\Model\\Layer\\Filter\\Category', ['layer' => $layer]);
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:7,代码来源:CategoryTest.php

示例2: _getCategory

 /**
  * Get Category from request
  *
  * @return Category
  */
 protected function _getCategory()
 {
     if (!$this->_category) {
         $this->_category = $this->_objectManager->create('Magento\\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:aiesh,项目名称:magento2,代码行数:19,代码来源:Urlrewrite.php

示例3: testIsInRootCategoryList

 public function testIsInRootCategoryList()
 {
     $this->assertFalse($this->_model->isInRootCategoryList());
     $this->_model->unsetData();
     $this->_model->load(3);
     $this->assertTrue($this->_model->isInRootCategoryList());
 }
开发者ID:andrewhowdencom,项目名称:m2onk8s,代码行数:7,代码来源:CategoryTreeTest.php

示例4: 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:buskamuza,项目名称:magento2-skeleton,代码行数:8,代码来源:CategoryTest.php

示例5: _getCategory

 /**
  * Get Category from request
  *
  * @return Category
  */
 protected function _getCategory()
 {
     if (!$this->_category) {
         $this->_category = $this->_objectManager->create('Magento\\Catalog\\Model\\Category');
         $categoryId = (int) $this->getRequest()->getParam('category', 0);
         $urlRewrite = $this->_getUrlRewrite();
         if (!$categoryId && $urlRewrite->getId()) {
             $metaData = $urlRewrite->getMetadata();
             if ($urlRewrite->getEntityType() === self::ENTITY_TYPE_CATEGORY) {
                 $categoryId = $urlRewrite->getEntityId();
             } elseif (!empty($metaData['category_id'])) {
                 $categoryId = $metaData['category_id'];
             }
         }
         if ($categoryId) {
             $this->_category->load($categoryId);
         }
     }
     return $this->_category;
 }
开发者ID:Doability,项目名称:magento2dev,代码行数:25,代码来源:Rewrite.php

示例6: getFiltersValues

 /**
  * @param $params
  * @return \stdClass
  */
 public function getFiltersValues($params)
 {
     $filters = new \stdClass();
     if (isset($params['cat'])) {
         $filters->filter_hc_category = '';
         $category = $this->catalogCategory->load($params['cat']);
         $categories = explode('/', $category->getPath());
         foreach ($categories as $cat) {
             $name = $category = $this->catalogCategory->load($cat)->getName();
             if (strpos($name, '/') !== false) {
                 $name = str_replace('/', '\\/', $name);
             }
             $filters->filter_hc_category .= '/' . $name;
         }
         unset($params['cat']);
     }
     if (isset($params['price'])) {
         $prices = explode('-', $params['price']);
         if (!empty($prices[0])) {
             $filters->filter_from_incl_price = $prices[0];
         }
         if (!empty($prices[1])) {
             $filters->filter_to_incl_price = $prices[1];
         }
         unset($params['price']);
     }
     if (isset($params)) {
         $list = $this->factory->create();
         $list->load();
         foreach ($params as $param => $values) {
             $getAttribute = null;
             foreach ($list as $cat) {
                 if ($param == $cat->getName()) {
                     $getAttribute = $cat;
                 }
             }
             if ($getAttribute !== null) {
                 $values = html_entity_decode($values);
                 preg_match_all('!\\d+!', $values, $matches);
                 if (is_array($matches[0])) {
                     $attrValues = array();
                     $paramName = 'filter_' . $param;
                     foreach ($matches[0] as $id) {
                         $attribute = $attribute = $getAttribute->getSource()->getOptionText($id);
                         $attrValues[] = $attribute;
                     }
                     $filters->paramName = $attrValues;
                 }
             }
         }
     }
     return $filters;
 }
开发者ID:boxalino,项目名称:plugin-magento2,代码行数:57,代码来源:Data.php

示例7: _getCategory

 /**
  * Get Category from request
  *
  * @return Category
  */
 private function _getCategory()
 {
     if (!$this->_category) {
         $this->_category = $this->_objectManager->create('Magento\\Catalog\\Model\\Category');
         $categoryId = (int) $this->getRequest()->getParam('category', 0);
         if (!$categoryId && $this->_getUrlRewrite()->getId() && $this->_getUrlRewrite()->getEntityType() === self::ENTITY_TYPE_CATEGORY) {
             $categoryId = $this->_getUrlRewrite()->getEntityId();
         }
         if ($categoryId) {
             $this->_category->load($categoryId);
         }
     }
     return $this->_category;
 }
开发者ID:aiesh,项目名称:magento2,代码行数:19,代码来源:UrlRedirect.php

示例8: testDeleteChildren

 /**
  * @magentoAppArea adminhtml
  */
 public function testDeleteChildren()
 {
     $this->_model->unsetData();
     $this->_model->load(4);
     $this->_model->setSkipDeleteChildren(true);
     $this->_model->delete();
     $this->_model->unsetData();
     $this->_model->load(5);
     $this->assertEquals($this->_model->getId(), 5);
     $this->_model->unsetData();
     $this->_model->load(3);
     $this->assertEquals($this->_model->getId(), 3);
     $this->_model->delete();
     $this->_model->unsetData();
     $this->_model->load(5);
     $this->assertEquals($this->_model->getId(), null);
 }
开发者ID:BlackIkeEagle,项目名称:magento2-continuousphp,代码行数:20,代码来源:CategoryTest.php

示例9: testSaveCategoryWithPosition

 /**
  * @magentoDataFixture Magento/Catalog/_files/category_with_position.php
  */
 public function testSaveCategoryWithPosition()
 {
     $category = $this->_model->load('444');
     $this->assertEquals('5', $category->getPosition());
 }
开发者ID:koliaGI,项目名称:magento2,代码行数:8,代码来源:CategoryTest.php

示例10: load

 /**
  * {@inheritdoc}
  */
 public function load($modelId, $field = null)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'load');
     if (!$pluginInfo) {
         return parent::load($modelId, $field);
     } else {
         return $this->___callPlugins('load', func_get_args(), $pluginInfo);
     }
 }
开发者ID:HaonanXu,项目名称:der-snack-backup,代码行数:12,代码来源:Interceptor.php


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