本文整理汇总了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]);
}
示例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;
}
示例3: testIsInRootCategoryList
public function testIsInRootCategoryList()
{
$this->assertFalse($this->_model->isInRootCategoryList());
$this->_model->unsetData();
$this->_model->load(3);
$this->assertTrue($this->_model->isInRootCategoryList());
}
示例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());
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例9: testSaveCategoryWithPosition
/**
* @magentoDataFixture Magento/Catalog/_files/category_with_position.php
*/
public function testSaveCategoryWithPosition()
{
$category = $this->_model->load('444');
$this->assertEquals('5', $category->getPosition());
}
示例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);
}
}