本文整理汇总了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;
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}