check product not only update qty to zero but also not deactivate

DATA CENTER SQL

select * from product_simple where
sku not in(
select s.sku from product_simple as s inner join db_update as u on u.sku= s.sku where s.qty =0 and u.qty=0
)and sku not in(
select s.sku from product_simple as s inner join db_deactivate as u on u.sku= s.sku where s.qty =0
)
and qty=0 and Marque_nom in (‘Saint-Laurent’,’Gucci’)

Magento:

public function getqtyAction()
    {
        $prefix=Mage::getBaseDir() ;
        $path_setting_shape=$prefix.'/json/not_qty.json';
        $file_shape_json=file_get_contents( $path_setting_shape);
        if($file_shape_json!=false) {
            $arr_shape_json = json_decode($file_shape_json);
            if ($arr_shape_json != null && $arr_shape_json != false) {

               foreach($arr_shape_json as $j)
               {

                   $_pro=Mage::getModel('catalog/product')->getCollection()->addAttributeToFilter('sku', $j->sku)->getFirstItem();
                   $id_selected=$_pro->getId();

/*
                   $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id_selected);
                   $qtyStock->setIsInStock(1);
                   $qtyStock->setQty(1);
                   $qtyStock->save();
*/


                   $qtyStock = Mage::getModel('cataloginventory/stock_item')->loadByProduct($id_selected);
                   echo $qtyStock->getIsInStock();
                   echo '  ';
                   echo $qtyStock->getQty();
                   echo '<br/>';
               }
            }
        }

Leave a Comment