0

I'm using to feed between my magento website and my ERP. The first one is from ERP to and update the stock information of ALL PRODUCTS.

The second one is from magento to the ERP and update information like price, brand, ... This one is based on the updated_at, we are sending only the products which has changed.

But, because of the first script, all products have changed. Then i would like to keep the previous updated_at date in my first script. I've tried this :

$product->setUpdatedAt($product->getUpdatedAt()); 

but it's not working. Is there a way to do this ?

Thx

1 Answer 1

0

I would suggest using direct SQL statements which will then bypass the updated_at attribute update which is on-save. For instance:

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$sql = 'UPDATE `cataloginventory_stock_item` SET `qty` = ? WHERE `product_id` = ?';
$connection->query($sql, array($your_desired_qty, $your_product_id));
//etc.

This is sort of frowned upon due to the nature of direct SQL action, but it's extremely quick and also lets you achieve your goal, just be careful with what you tamper with.

P.S. You'll need to update your price in the EAV tables, not the flat tables as these changes will not reflect on the frontend.

For instance:

$connection = Mage::getSingleton('core/resource')->getConnection('core_write');
$sql = 'UPDATE `catalog_product_entity_decimal` SET `value` = ? WHERE `entity_id` = ? AND `attribute_id` = ?';
$connection->query($sql, array($your_product_id, $your_price_attribute_id));

Let me know if you have any issues.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.