Wednesday, 9 September 2015

When On Particular Category adding a product in admin side then product name should be created automatically using product attributes like weight,sizing Magento


I am Adding Product Admin Side. But When Particular category then it can be automatically
generate Product name. like it's Attributes. I Give Reference for that I give Example For That.

Create Simple Module.


Create Easylife_Meta.xml Here.

<?xml version="1.0"?>
                <Mage_Catalog />


Create config.xml

<?xml version="1.0"?>


Create File Observer.php


class Easylife_Meta_Model_Observer
    public function createName($observer)
        $product = $observer->getEvent()->getProduct();
       $data = $observer->getEvent()->getCategory();
        $product_category_id = $product['category_ids'];
        $productColor = $product->getWeight('weight');
        $productsizing = $product->getAttributeText('sizing');
       if (!empty($product_category_id)) {
        if (in_array("9", $product_category_id)){ // Here 9 in My Category ID
            $productSku = $productColor." ".$productsizing;

Here You can generate name for particular category. you can also change all product remoce if
contion  $product->setName($productSku); set here your value. here 9 is my category
you can check your category id then check it.

No comments:

Post a Comment

Thank You For Comment