I want to create a CRON job which updates my Magento products Inventory by matching sku and product name with the third party products inventory. third party is using Sql server and my Magento project is on MySql.


you have to write a webservice which will get pass sku and get the qty for that product and use following code to update $qty at magento product.

The following code uses magento soap api to update qty of the product

<?php $client = new SoapClient('http://www.yourdomain.com/index.php/api/v2_soap?wsdl=1');
$session = $client->login($soapusername,$soappassword); // soap user name and password

$products = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*')->addAttributeToFilter('product_category_id',4)->addFieldToFilter('attribute_set_id', $attributeSetId);

foreach($products as $product)
    $quantity = write a funtion which will take the sku of the product and get the qty of that product
    $qty = array();
    if($qty > 0 ){
        $qty['qty'] = $quantity;
        $qty['is_in_stock'] = 1;
        $qty['qty'] = 0;
        $qty['is_in_stock'] = 0;


Note:- write the above code in cron.this is the code which will update stock of product in magento

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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