Change Magento default status for duplicated products

后端 未结 2 773
故里飘歌
故里飘歌 2020-11-29 13:21

I have a Magento store installed, and when a product is duplicated in the backend, Magento sets its status to Disabled by default. I don\'t want that to happen, the duplicat

相关标签:
2条回答
  • 2020-11-29 13:58

    I found error on this code and find out the solution below:

    On app/code/local/MagePal/EnableDuplicateProductStatus/etc/config.xml change

    <method> duplicateProduct </method>
    

    TO

    <method>productDuplicate</method>
    
    0 讨论(0)
  • 2020-11-29 14:13

    Try this:

    Create: app/code/local/MagePal/EnableDuplicateProductStatus/etc/config.xml

    <?xml version="1.0"?>
    <config>
        <modules>
            <MagePal_EnableDuplicateProductStatus>
                <version>1.0.1</version>
            </MagePal_EnableDuplicateProductStatus>
        </modules>
    
        <global>
            <models>
                <enableduplicateproductstatus>
                    <class>MagePal_EnableDuplicateProductStatus_Model</class>
                </enableduplicateproductstatus>
            </models>
             <events>
                <catalog_model_product_duplicate>
                    <observers>
                        <enableduplicateproductstatus>
                            <type>singleton</type>
                            <class>enableduplicateproductstatus/observer</class>
                            <method>productDuplicate</method>
                        </enableduplicateproductstatus>
                    </observers>
                </catalog_model_product_duplicate>
            </events>
        </global>
    </config>
    

    Create: app/code/local/MagePal/EnableDuplicateProductStatus/Model/Observer.php

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

    Create: app/etc/modules/MagePal_EnableDuplicateProductStatus.xml

      <?xml version="1.0"?>
        <config>
               <modules>
                      <MagePal_EnableDuplicateProductStatus>
                              <active>true</active>
                              <codePool>local</codePool>
                      </MagePal_EnableDuplicateProductStatus>
               </modules>
        </config>
    

    Then clear cache and try duplicating a product.

    read more @ :

    http://magento4u.wordpress.com/2009/06/08/create-new-module-helloworld-in-magento/

    http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/customizing_magento_using_event-observer_method

    make a new product active by default in magento

    0 讨论(0)
提交回复
热议问题