Sometimes when using EDI(Electronic data interchange) we need to update the product attributes in magento
For example EDI846 which deals with product stock
So how can we do this lets see
First of all we need to process the edi files and get the sku and qty from it
and rest of them is as shown below in the code snippet

$product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
$productId = $product->getId();
$stockItem =Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
$stockItemId = $stockItem->getId();
$stockItem->setData('is_in_stock', 1);
$stockItem->setData('qty', (integer)$qty);

So with not much effort we can update products stock by code in magento

Leave a Reply

Your email address will not be published. Required fields are marked *