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


PHP Category::getPathInStore方法代碼示例

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


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

示例1: getParentCategories

 /**
  * Return parent categories of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @return \Magento\Framework\Object[]
  */
 public function getParentCategories($category)
 {
     $pathIds = array_reverse(explode(',', $category->getPathInStore()));
     /** @var \Magento\Catalog\Model\Resource\Category\Collection $categories */
     $categories = $this->_categoryCollectionFactory->create();
     return $categories->setStore($this->_storeManager->getStore())->addAttributeToSelect('name')->addAttributeToSelect('url_key')->addFieldToFilter('entity_id', array('in' => $pathIds))->addFieldToFilter('is_active', 1)->load()->getItems();
 }
開發者ID:pavelnovitsky,項目名稱:magento2,代碼行數:13,代碼來源:Category.php

示例2: testGetPathInStore

 public function testGetPathInStore()
 {
     $this->_model->load(5);
     $this->assertEquals('5,4,3', $this->_model->getPathInStore());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:5,代碼來源:CategoryTreeTest.php

示例3: getParentCategories

 /**
  * Return parent categories of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param bool $isActive
  * @return \Magento\Catalog\Model\Category[]
  */
 public function getParentCategories($category, $isActive = true)
 {
     $categories = array();
     $read = $this->_getReadAdapter();
     $select = $read->select()->from(array('main_table' => $this->getMainStoreTable($category->getStoreId())), array('main_table.entity_id', 'main_table.name'))->joinLeft(array('url_rewrite' => $this->getTable('core_url_rewrite')), 'url_rewrite.category_id=main_table.entity_id AND url_rewrite.is_system=1 AND ' . $read->quoteInto('url_rewrite.product_id IS NULL AND url_rewrite.store_id=? AND ', $category->getStoreId()) . $read->prepareSqlCondition('url_rewrite.id_path', array('like' => 'category/%')), array('request_path' => 'url_rewrite.request_path'))->where('main_table.entity_id IN (?)', array_reverse(explode(',', $category->getPathInStore())));
     if ($isActive) {
         $select->where('main_table.is_active = ?', '1');
     }
     $select->order('main_table.path ASC');
     $result = $this->_getReadAdapter()->fetchAll($select);
     foreach ($result as $row) {
         $row['id'] = $row['entity_id'];
         $categories[$row['entity_id']] = $this->_categoryFactory->create()->setData($row);
     }
     return $categories;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:23,代碼來源:Flat.php

示例4: getParentCategories

 /**
  * Return parent categories of category
  *
  * @param \Magento\Catalog\Model\Category $category
  * @param bool $isActive
  * @return \Magento\Catalog\Model\Category[]
  */
 public function getParentCategories($category, $isActive = true)
 {
     $categories = [];
     $read = $this->_getReadAdapter();
     $select = $read->select()->from(['main_table' => $this->getMainStoreTable($category->getStoreId())], ['main_table.entity_id', 'main_table.name'])->joinLeft(['url_rewrite' => $this->getTable('url_rewrite')], 'url_rewrite.entity_id = main_table.entity_id AND url_rewrite.is_autogenerated = 1' . $read->quoteInto(' AND url_rewrite.store_id = ?', $category->getStoreId()) . $read->quoteInto(' AND url_rewrite.entity_type = ?', CategoryUrlRewriteGenerator::ENTITY_TYPE), ['request_path' => 'url_rewrite.request_path'])->where('main_table.entity_id IN (?)', array_reverse(explode(',', $category->getPathInStore())));
     if ($isActive) {
         $select->where('main_table.is_active = ?', '1');
     }
     $select->order('main_table.path ASC');
     $result = $this->_getReadAdapter()->fetchAll($select);
     foreach ($result as $row) {
         $row['id'] = $row['entity_id'];
         $categories[$row['entity_id']] = $this->_categoryFactory->create()->setData($row);
     }
     return $categories;
 }
開發者ID:shabbirvividads,項目名稱:magento2,代碼行數:23,代碼來源:Flat.php

示例5: getPathInStore

 /**
  * {@inheritdoc}
  */
 public function getPathInStore()
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getPathInStore');
     if (!$pluginInfo) {
         return parent::getPathInStore();
     } else {
         return $this->___callPlugins('getPathInStore', func_get_args(), $pluginInfo);
     }
 }
開發者ID:HaonanXu,項目名稱:der-snack-backup,代碼行數:12,代碼來源:Interceptor.php


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