Hello,
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.
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.
app\etc\modules
Create Easylife_Meta.xml Here.
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Meta>
<codePool>local</codePool>
<active>true</active>
<depends>
<Mage_Catalog />
</depends>
</Easylife_Meta>
</modules>
</config>
app\code\local\Easylife\Meta\etc
Create config.xml
<?xml version="1.0"?>
<config>
<modules>
<Easylife_Meta>
<version>0.0.1</version>
</Easylife_Meta>
</modules>
<global>
<models>
<easylife_meta>
<class>Easylife_Meta_Model</class>
</easylife_meta>
</models>
</global>
<adminhtml>
<events>
<catalog_product_save_before>
<observers>
<create_name>
<class>easylife_meta/observer</class>
<method>createName</method>
</create_name>
</observers>
</catalog_product_save_before>
</events>
</adminhtml>
</config>
\app\code\local\Easylife\Meta\Model
Create File Observer.php
<?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;
$product->setName($productSku);
}
}
}
}
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.
0 komentar:
Post a Comment