在magento中默认启用新产品 [英] make a new product active by default in magento

查看:90
本文介绍了在magento中默认启用新产品的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在magento的后端中复制产品时,默认情况下,新产品状态为禁用".这使希望产品在前端显示的商店管理员感到困惑.

When duplicating a product in the backend in magento the new product status is Disabled by default. That confuses the store admins who expect the product to show on the frontend.

如何默认使产品状态为启用"?

How can I make the product status Enabled by default?

谢谢

推荐答案

在您的自定义模块中,您需要:

In your custom module you need to:

在config.xml文件中:

in config.xml file:

<config>
    <adminhtml>
        <events>
            <catalog_model_product_duplicate>
                <observers>
                    <custom_catalog_product_duplicate>
                        <class>custom_module/observer</class>
                        <method>catalogModelProductDuplicate</method>
                    </custom_catalog_product_duplicate>
                </observers>
            </catalog_model_product_duplicate>
        </events>
    </adminhtml>
</config>

使用如下方法创建观察者类:

Create an observer class with method like this:

class Custom_Module_Model_Observer 
{
    /**
     * Prepare product for duplicate action.
     *
     * @param Varien_Event_Observer $observer
     * @return object
     */
    public function catalogModelProductDuplicate(Varien_Event_Observer  $observer)
    {
        $newProduct = $observer->getEvent()->getNewProduct();
        $newProduct->setStatus(Mage_Catalog_Model_Product_Status::STATUS_ENABLED);

        return $this;
    }
}

这篇关于在magento中默认启用新产品的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆