在比较视图中显示已停用/已停用的产品

Mr_*_*een 7 php magento magento-1.8

我正在尝试在比较视图中显示产品,该视图status = disabled通过管理面板设置.

在默认的magento中,这似乎是不可能的,因为禁用的产品在产品列表页面产品详细信息页面中不可见.

不知何故,我设法通过覆盖在产品列表页面产品详细信息页面中显示已禁用的产品Mage_Catalog_Helper_Product.在那里我评论了以下代码:

    // if (!$this->canShow($product)) {
    //     return false;
    // }
Run Code Online (Sandbox Code Playgroud)

现在,有人帮我了解如何在比较视图中显示残疾产品吗?

Mr_*_*een 4

在搜索了很长时间并且未能从法师核心文件中提取解决方案后,我创建了一个与属性相同的属性status。我将该属性命名为Archive(是/否)。这个新属性将证明产品是否停产。

最后,我仅过滤与此新属性相关的所有产品列表、产品详细信息和主页Archive

我计划编写一个 MVC 操作,它将更改所有产品statusenabled同时触发产品Archive的 as yes status = disabled。我很快就会在这里分享代码。

代码

编写一个虚拟控制器,在调用 url 时运行以下代码:

public function updateproductsAction() {
    Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);

    $collectionConfigurable = Mage::getResourceModel('catalog/product_collection')
            ->addAttributeToFilter('type_id', array('eq' => 'configurable'))
            ->addAttributeToFilter('entity_id', array('gt' => 0));      // This line should be removed to affect all the configurable products. (to avoid execution time-out)

    echo 'Total are ' . count($collectionConfigurable) . '<br/>';
    $i = 1;                         
    foreach($collectionConfigurable as $p) {
        $product = Mage::getModel('catalog/product')->load($p->getId());
        $product->save();
        echo $i++ . ') The product Id with ' . $p->getId() . " is done...." . "<br/>";  // if the execution time-out occurs, note down the last product id and change the value above in addAttributeToFilter. so the execution runs from the last stopped product.
    }
}
Run Code Online (Sandbox Code Playgroud)