如果我有两个产品系列,有没有办法将它们合并为一个?
例如(我的最终目的不是实际上只获得2只猫的集合,这只是为了说明问题):
$collection1 = Mage::getModel('catalog/category')->load(148)->getProductCollection();
$collection2 = Mage::getModel('catalog/category')->load(149)->getProductCollection();
$merged_collection = merge_collections($collection1,$collection2);
Run Code Online (Sandbox Code Playgroud)
任何帮助,将不胜感激!
因此,我们将"最近查看过的"块放入我们的产品视图中.一开始看起来一切看起来都不错,但我现在看到与null布局有关的奇怪错误.如果我关闭缓存它工作正常,但启用完整页面缓存时调用$ this-> getColumnCount(); 在模板中.
我最近在产品页面上查看过的内容是:
在catalog_product_view的内容块中的catalog.xml中:
<block type="reports/product_viewed" name="reports.product.viewed" as="recently_viewed" template="reports/product_viewed.phtml">
<action method="setColumnCount"><columns>4</columns></action>
<action method="setItemLimit"><type>recently_viewed</type><limit>4</limit></action>
</block>
Run Code Online (Sandbox Code Playgroud)
在模板文件中:catalog/product/view.phtml:
<?php echo $this->getChildHtml('recently_viewed') ?>
Run Code Online (Sandbox Code Playgroud)
一切都很好,第一次加载,但如果我点击另一个产品视图,然后重新加载它错误的页面.我将错误追溯到了类:Mage_Page_Helper_Layout.
函数getCurrentPageLayout(),有一行:
$this->getLayout()->getBlock('root')
Run Code Online (Sandbox Code Playgroud)
和$ this-> getLayout返回null,导致getBlock调用抛出异常.
如果我禁用缓存没有错误出现,一切正常.