[英]Magento sub-categories URL redirects to 404
Magento Version: 1.8 CE Magento版本:1.8 CE
I have 2 stores: Store 1 and Store 2 我有2家商店:1号商店和2号商店
Store 1's root category has sub categories A, B and C 商店1的根类别具有子类别A,B和C
I wanted Store 2 to list all the sub-categories from Store A(ie A, B and C) 我希望商店2列出商店A中的所有子类别(即A,B和C)
This is the code I am using now: 这是我现在使用的代码:
$_rootCatId = 7;
$_rootCategory = Mage::getModel('catalog/category')->load($_rootCatId);
$collection = $_rootCategory->getChildrenCategories();
$helper = Mage::helper('catalog/category');
foreach ($collection as $cat) {
if($cat->getIsActive()==1)
{
echo $cat->getURL();
echo $cat->getName();
}
}
This lists all the subcategories, but the corresponding URLs redirect to 404. 这列出了所有子类别,但是相应的URL重定向到404。
However, if I change the root category of Store 2 to the same as Store 1, it gives the same URL and is listing all the products. 但是,如果我将商店2的根类别更改为与商店1相同,则它会提供相同的URL并列出所有产品。 Is this because magento restricts access to those sub-categories which does not come under the root category of the current store?
这是因为magento限制了对那些不在当前商店的根类别下的子类别的访问吗?
I am new to magento and wanted to know if this is possible, ie listing all the products within another store's sub-category. 我是magento的新手,想知道这是否可行,即列出另一家商店的子类别中的所有产品。
Try adding store filter to your $_rootCategory. 尝试将商店过滤器添加到$ _rootCategory。 eg
例如
$_rootCategory = Mage::getModel('catalog/category')->setStoreId(1)->load($_rootCatId);
我在目录/类别帮助器中覆盖了canShow()函数,以忽略isRootCategory()并奏效。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.