コード例 #1
0
 /**
  * Get categories assigned to product
  *
  * @return \Magento\Catalog\Model\Resource\Category\Collection
  */
 protected function getCategories()
 {
     if (!$this->categories) {
         $this->categories = $this->product->getCategoryCollection();
         $this->categories->addAttributeToSelect('url_key');
         $this->categories->addAttributeToSelect('url_path');
     }
     return $this->categories;
 }
コード例 #2
0
ファイル: Tree.php プロジェクト: aiesh/magento2
 /**
  * @return void
  */
 protected function prepareCollection()
 {
     $storeId = $this->storeManager->getStore()->getId();
     $this->categoryCollection->addAttributeToSelect('name')->addAttributeToSelect('is_active')->setProductStoreId($storeId)->setLoadProductCount(true)->setStoreId($storeId);
 }