By Ruud Kok


2012-10-01 17:22:06 8 Comments

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 duplicated product should have its status copied from the original product as well.

In this post a partial solution was given. I see where I can find the config.xml and make the necessarry changes. However, where do I put such an observer class? Which file should I use/create and would that require any changes to the config.xml input?

Or does somebody have an overall solution for this issue? Thanks in advance!

2 comments

@Renon Stewart 2012-10-02 19:10:34

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

@Ruud Kok 2012-10-09 08:49:00

Unfortunately this still doesn't work. I found 1 error in the config.xml (which says "<class>enableduplicateproductstatus/observer</class>" where I think it should be "<class>enableduplicateproductstatus/model/observer</class>" because of where you put the Oberserver.php. After clearing the cache and duplicating a product, the new product still has the disabled status.

@Renon Stewart 2012-10-09 17:09:13

Try the code now... I tested it and it work... <models> was not define in previous

@Renon Stewart 2012-10-09 20:21:20

Also the <class> tag is not a error.

@user2283211 2013-04-15 16:04:48

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>

Related Questions

Sponsored Content

23 Answered Questions

[SOLVED] Find duplicate records in MySQL

  • 2009-05-12 18:24:21
  • Chris Bartow
  • 726610 View
  • 617 Score
  • 23 Answer
  • Tags:   mysql duplicates

28 Answered Questions

[SOLVED] Finding duplicate values in a SQL table

  • 2010-04-07 18:17:29
  • Alex
  • 2523827 View
  • 1708 Score
  • 28 Answer
  • Tags:   sql duplicates

45 Answered Questions

[SOLVED] Removing duplicates in lists

4 Answered Questions

[SOLVED] Change Magento product status in different store views

54 Answered Questions

[SOLVED] Remove duplicate values from JS array

37 Answered Questions

[SOLVED] How can I remove duplicate rows?

1 Answered Questions

[SOLVED] Magento how to change the default order status in Paypal

1 Answered Questions

[SOLVED] make a new product active by default in magento

1 Answered Questions

[SOLVED] how status of Product in Magento get changed/saved?

1 Answered Questions

How to change Magento Order Status Default Flow?

  • 2012-05-14 07:01:41
  • Ruiwant
  • 1544 View
  • 0 Score
  • 1 Answer
  • Tags:   magento

Sponsored Content