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


PHP Mage_Catalog_Model_Category::getIsAnchor方法代碼示例

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


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

示例1: apply

 /**
  * Apply category filter to layer
  *
  * @param   Zend_Controller_Request_Abstract $request
  * @param   Mage_Core_Block_Abstract $filterBlock
  * @return  Mage_Catalog_Model_Layer_Filter_Category
  */
 public function apply(Zend_Controller_Request_Abstract $request, $filterBlock)
 {
     $filter = (int) $request->getParam($this->getRequestVar());
     if (!$filter) {
         return $this;
     }
     // load data for applied category
     $this->_appliedCategory = Mage::getModel('catalog/category')->setStoreId(Mage::app()->getStore()->getId())->load($filter);
     if ($this->_appliedCategory->getId()) {
         // create join and conditions for additional category filter
         $tableAlias = 'category_layered_' . $this->_rootCategory->getId();
         $conditions = array();
         $conditions['category_id'] = $filter;
         $conditions['store_id'] = Mage::app()->getStore()->getId();
         if (!$this->_appliedCategory->getIsAnchor()) {
             $conditions['is_parent'] = 1;
         }
         $this->getLayer()->getProductCollection()->joinTable(array($tableAlias => 'catalog/category_product_index'), "product_id=entity_id", array($tableAlias . '_cat_id' => 'category_id', $tableAlias . '_store_id' => 'store_id'), $conditions, 'inner');
         // add filter to layer state
         $this->getLayer()->getState()->addFilter($this->_createItem($this->_appliedCategory->getName(), $filter));
         // if current applied category has no children reset items array (for hiding filter block)
         if (!$this->_appliedCategory->getChildrenCategories()) {
             $this->_items = array();
         }
     }
     return $this;
 }
開發者ID:bitbull-team,項目名稱:magento-module-category-layered,代碼行數:34,代碼來源:CategoryLayered.php

示例2: exportData

 protected function exportData(Mage_Catalog_Model_Category $category, $file, $depth = 0)
 {
     $data = array('id' => $category->getId(), 'parent_id' => $category->getParentId(), 'attribute_set_id' => $category->getAttributeSetId(), 'urlPath' => $category->getUrlPath(), 'urlKey' => $category->getUrlKey(), 'path' => $category->getPath(), 'position' => $category->getPosition(), 'page_layout' => $category->getPageLayout(), 'description' => $category->getDescription(), 'display_mode' => $category->getDisplayMode(), 'is_active' => $category->getIsActive(), 'is_anchor' => $category->getIsAnchor(), 'include_in_menu' => $category->getIncludeInMenu(), 'custom_design' => $category->getCustomDesign(), 'level' => $category->getLevel(), 'name' => $category->getName(), 'metaTitle' => $category->getMetaTitle(), 'metaKeywords' => $category->getMetaKeywords(), 'metaDescription' => $category->getMetaDescription());
     echo str_repeat('  ', $depth);
     echo '* ' . $category->getName() . sprintf(' (%s products)', $category->getProductCount()) . PHP_EOL;
     fputcsv($file, $data);
     if ($category->hasChildren()) {
         $children = Mage::getModel('catalog/category')->getCategories($category->getId());
         foreach ($children as $child) {
             $child = Mage::getModel('catalog/category')->load($child->getId());
             $this->exportData($child, $file, $depth + 1);
         }
     }
 }
開發者ID:sonaht,項目名稱:magento-category-migration,代碼行數:14,代碼來源:exportCategories.php

示例3: addCategoryFilter

 /**
  * Specify category filter for product collection
  *
  * @param   Mage_Catalog_Model_Category $category
  * @return  Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor()) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     $this->_query->setQuery($this->_queryString);
     if ($this->getStoreId() == Mage_Core_Model_App::ADMIN_STORE_ID) {
         //$this->_applyZeroStoreProductLimitations();
     } else {
         // $this->_applyProductLimitations();
     }
     return $this;
 }
開發者ID:RonXS,項目名稱:Solento,代碼行數:22,代碼來源:Collection.php

示例4: addCategoryFilter

 /**
  * Specify category filter for product collection
  *
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor()) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     if ($this->getStoreId() == Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID) {
         //FIXME: apply no store
         //$this->_applyZeroStoreProductLimitations();
     } else {
         //FIXME: apply stores
         //$this->_applyProductLimitations();
     }
     return $this;
 }
開發者ID:jokusafet,項目名稱:MagentoSource,代碼行數:23,代碼來源:Collection.php

示例5: addCategoryFilter

 /**
  * Specify category filter for product collection
  *
  * @param Mage_Catalog_Model_Category $category
  * @return Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor()) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     $this->_applyProductLimitations();
     return $this;
 }
開發者ID:hunnybohara,項目名稱:magento-chinese-localization,代碼行數:17,代碼來源:Collection.php

示例6: addCategoryFilter

 /**
  * Specify category filter for product collection
  *
  * @param   Mage_Catalog_Model_Category $category
  * @param   bool $renderAlias instruction for build category table alias based on category id
  * @return  Mage_Catalog_Model_Resource_Eav_Mysql4_Product_Collection
  */
 public function addCategoryFilter(Mage_Catalog_Model_Category $category, $renderAlias = false)
 {
     if ($renderAlias) {
         $alias = 'cat_index_' . $category->getId();
     } else {
         $alias = 'cat_index';
     }
     $categoryCondition = $this->getConnection()->quoteInto($alias . '.product_id=e.entity_id AND ' . $alias . '.store_id=? AND ', $this->getStoreId());
     if ($category->getIsAnchor()) {
         $categoryCondition .= $this->getConnection()->quoteInto($alias . '.category_id=?', $category->getId());
     } else {
         $categoryCondition .= $this->getConnection()->quoteInto($alias . '.category_id=? AND ' . $alias . '.is_parent=1', $category->getId());
     }
     $this->getSelect()->joinInner(array($alias => $this->getTable('catalog/category_product_index')), $categoryCondition, array('position' => 'position'));
     $this->_categoryIndexJoined = true;
     $this->_joinFields['position'] = array('table' => $alias, 'field' => 'position');
     //        $this->joinField(
     //            $alias,
     //            'catalog/category_product_index',
     //            'position',
     //            'product_id=entity_id',
     //            $categoryCondition
     //        );
     return $this;
 }
開發者ID:ronseigel,項目名稱:agent-ohm,代碼行數:32,代碼來源:Resource_Eav_Mysql4_Product_Collection.php

示例7: addCategoryFilter

 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor()) {
         $this->getSelect()->where('available_category_ids:' . $category->getId());
     } else {
         $this->getSelect()->where('available_category_ids:' . $category->getId());
     }
     return $this;
 }
開發者ID:georgebabarus,項目名稱:Magento-Solr,代碼行數:10,代碼來源:AbstractCollection.php

示例8: addCategoryFilter

 /**
  * add category filter to collection
  *
  * @param Mage_Catalog_Model_Category $category
  */
 public function addCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     $this->_productLimitationFilters['category_id'] = $category->getId();
     if ($category->getIsAnchor() == 1) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     $this->_fieldMap['position'] = 'category_sort.category_' . $category->getId();
     return $this;
 }
開發者ID:Mohitsahu123,項目名稱:Elasticgento,代碼行數:16,代碼來源:Collection.php

示例9: pushCategoryFilter

 /**
  * Add category filter to product collection
  *
  * @param Mage_Catalog_Model_Category $category Category
  * @return Mage_Catalog_Model_Resource_Product_Collection
  */
 public function pushCategoryFilter(Mage_Catalog_Model_Category $category)
 {
     if (is_array($this->_productLimitationFilters['category_id'])) {
         $this->_productLimitationFilters['category_id'][] = $category->getId();
     } else {
         $this->_productLimitationFilters['category_id'] = array($category->getId());
     }
     if ($category->getIsAnchor()) {
         unset($this->_productLimitationFilters['category_is_anchor']);
     } else {
         $this->_productLimitationFilters['category_is_anchor'] = 1;
     }
     if ($this->getStoreId() == Mage_Catalog_Model_Abstract::DEFAULT_STORE_ID) {
         $this->_applyZeroStoreProductLimitations();
     } else {
         $this->_applyProductLimitations();
     }
     return $this;
 }
開發者ID:kumardhirendra1,項目名稱:Magento_Filter,代碼行數:25,代碼來源:Collection.php

示例10: addCategoryFilter

 public function addCategoryFilter(Mage_Catalog_Model_Category $category, $renderAlias = false)
 {
     if ($category->getIsAnchor()) {
         $categoryCondition = $this->getConnection()->quoteInto('{{table}}.category_id IN (?)', explode(',', $category->getAllChildren()));
         $this->getSelect()->group('e.entity_id');
     } else {
         $categoryCondition = $this->getConnection()->quoteInto('{{table}}.category_id=?', $category->getId());
     }
     if ($renderAlias) {
         $alias = 'category_' . $category->getId();
     } else {
         $alias = 'position';
     }
     $this->joinField($alias, 'catalog/category_product', 'position', 'product_id=entity_id', $categoryCondition);
     return $this;
 }
開發者ID:arslbbt,項目名稱:mangentovies,代碼行數:16,代碼來源:Collection.php


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