I nedd to add a specific attribute to products where product name contains "sometingh". Example: Product Name: "shoes ARMANI leather patent" Attribute Designer: empty I would add ARMANI to attribue DESIGNER for all products that have on NAME the word "ARMANI".
Asked
Active
Viewed 253 times
1 Answers
1
Yon can do that using an external magento script,
1) load a collection of product having "something" in name
2) loop through the collection, set the attribute, save the product
include 'app/Mage.php';
Mage::app();
$collection = Mage::getModel('catalog/product')->getCollection();
$collection->addAttributeToSelect('name');
$collection->addAttributeToSelect('designer');
$collection->addAttributeToFilter('name', array('like' => '%ARMANI%'));
foreach ($collection as $product)
{
echo 'product ' . $product->getSku();
$product->setData('designer','Armani');
$product->save();
}
}
a quicker vai to save only one attribute of a product is to replace the
$product->save();
with
$product->getResource()->saveAttribute($product, 'designer');
hope this helps
Giuseppe
- 1,131
- 8
- 12