更改 Magento 类别布局


Change Magento Category Layout

我需要以编程方式更新Magento +随机化产品顺序中数千个类别的页面布局。这是一段代码:

        /* @var $_childColorCategory Mage_Catalog_Model_Category */
        $_childColorCategory = Mage::getModel('catalog/category')->load($_childColorId);
        /* positions rand */
        $_positions = $_childColorCategory->getProductsPosition();
        if (count($_positions) > 1) {
            $_order = range(1, count($_positions));
            shuffle(&$_order);
            $_newPositions = array_combine(array_keys($_positions), $_order);
            $_childColorCategory->setPostedProducts($_newPositions);
        }
        $_childColorCategory
                ->setPageLayout('two_columns_right')
                ->save();

当然,这一切都在循环中等。

问题是布局没有更新(嵌套产品的顺序更改得很好):我在仪表板中看到所有受影响的类别都有正确的("two_columns_right")布局,但在手动单击管理员保存按钮之前,它实际上不适用于前端。如果我单击按钮(不进行任何更改),那么布局实际上在前端变得正确,而且 - 对该类别的任何进一步编程布局更改都运行良好。有什么想法吗?谢谢

附言这不是 100% 的缓存问题。Magento更新到1.7 - 没有运气。多商店设置(4个网站)。

在 magento 中,所有布局更改都在 xml 文件中,更多信息在 http://www.magentocommerce.com/design_guide/articles/intro-to-layouts

对于类别布局,您在此处有 anwserhttp://www.magentocommerce.com/boards/viewthread/16838/

但是显示随机化产品是非常糟糕的主意,因为 magento 会非常慢。