本文整理汇总了PHP中Mage_Catalog_Model_Category::getAllChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Catalog_Model_Category::getAllChildren方法的具体用法?PHP Mage_Catalog_Model_Category::getAllChildren怎么用?PHP Mage_Catalog_Model_Category::getAllChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Catalog_Model_Category
的用法示例。
在下文中一共展示了Mage_Catalog_Model_Category::getAllChildren方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetAllChildren
public function testGetAllChildren()
{
$this->_model->load(4);
$this->assertEquals('4,5', $this->_model->getAllChildren());
$this->_model->load(5);
$this->assertEquals('5', $this->_model->getAllChildren());
}
示例2: move
public function move(Mage_Catalog_Model_Category $category, $newParentId)
{
$oldStoreId = $category->getStoreId();
$parent = Mage::getModel('catalog/category')->setStoreId($category->getStoreId())->load($category->getParentId());
$newParent = Mage::getModel('catalog/category')->setStoreId($category->getStoreId())->load($newParentId);
$oldParentStores = $parent->getStoreIds();
$newParentStores = $newParent->getStoreIds();
$category->setParentId($newParentId)->save();
$parent->save();
$newParent->save();
// Add to new stores
$addToStores = array_diff($newParentStores, $oldParentStores);
foreach ($addToStores as $storeId) {
$newCategory = clone $category;
$newCategory->setStoreId($storeId)->save();
$children = $category->getAllChildren();
if ($children && ($arrChildren = explode(',', $children))) {
foreach ($arrChildren as $childId) {
if ($childId == $category->getId()) {
continue;
}
$child = Mage::getModel('catalog/category')->setStoreId($oldStoreId)->load($childId)->setStoreId($storeId)->save();
}
}
}
return $this;
}
示例3: _getValidIdsForCategory
/**
* For a given category, get all ids to other categories related to it.
*
* For a normal category, add ids of all it's parents
* For an anchor - also add all it's children
*
* @param Mage_Catalog_Model_Category $category
* @return array
*/
protected function _getValidIdsForCategory(Mage_Catalog_Model_Category $category)
{
return explode(',', $category->getAllChildren());
}
示例4: 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;
}