You are viewing an old revision of this post, from September 21, 2017 @ 16:31:39. See below for differences between this version and the current revision.

Magento – The fastest way to update a product attribute

In a beautiful day, my client requires updating the product stock status for around 200,000 products in Magento, the data gets from the XML files. The issue is the XML files will be renewed every day, it means I need to finish updating all products within 24 hours.

There is a problem for 200,000 products if I use the normal way to update products.

Generally, it only can update some thousand products every day with the method save() in product action.

I have found out the faster way to update 200,000 products within 24 hours.

Here is how to do

$product = Mage::getModel('catalog/product')->load($product_id);
$resource = $product->getResource();
$product->setData($attribue_code, $value);
$resource->saveAttribute($product, $attribute_code); 

This method requires loading the product, but it doesn't trigger the reindex event, that is the reason why it is faster.

Hope it is useful for you 🙂

Revisions

  • September 21, 2017 @ 16:31:39 [Current Revision] by Sharing Solution
  • September 21, 2017 @ 16:31:39 by Sharing Solution

Revision Differences

There are no differences between the September 21, 2017 @ 16:31:39 revision and the current revision. (Maybe only post meta information was changed.)

No comments yet.

Leave a Reply