I have been practicing and studying PHP as a hobby and today I faced with something that I thought was easy to do.
Firstly I take all the information from a XML file then I update all the stock information but just if the product is present in the file, the problem here is if the product isn't on the file the product can't be updated and the stock will be preserved.
An example of this problem is that when I import the products from the XML and this isn't present any more there because the manufacturer stop producing it I will conserve the stock in the database even if the product isn't selling anymore.
So I need to set to 0 my stock if the product is not longer available in the XML file, I wrote this already but how can I add a Logical Operator or something similar to set my stock to 0 if there is not present the product any more in the file?
$item1 = array('Category' => (ucwords (mb_strtolower ($rec1[1], "iso-8859-1"))), 'SKU2' => $rec2[1], 'SKU' => $rec3[1], 'Name' => (ucwords (mb_strtolower ($rec4[1],'iso-8859-1'))), 'Price' => $price, 'Wholesale' => $wholesalepr, 'Stock' => $stockgdl, 'Image' => $rec5[1], 'Brand' => (ucwords (mb_strtolower ($rec9[1], "iso-8859-1"))), 'Subcategory' => (ucwords (mb_strtolower ($rec12[1], "iso-8859-1")))); if($item1['Stock']>0) { $out_of_stock="2"; $quantity = $item1['Stock']; } else { $out_of_stock="0"; $quantity = "0"; }
No comments:
Post a Comment