I need some help with an import tool for my website that imports CSV files and updates product information accordingly through the extension Related Options.
The code of subject is the following
Code: Select all
public function getProductByModel($model, $manufacturers){
$query = $this->db->query("SELECT product_id FROM " . DB_PREFIX . "product WHERE model = '" . $this->db->escape($model) . "' AND manufacturer_id IN (" . implode(',', $manufacturers) . ") ORDER BY `date_available` DESC");
$result = $query->row;
if($result && count($result)>0){
$this->db->query("UPDATE " . DB_PREFIX . "product SET status = 0 WHERE model = '" . $this->db->escape($model) . "' AND manufacturer_id IN (" . implode(',', $manufacturers) . ") AND quantity < 1");
$this->db->query("UPDATE " . DB_PREFIX . "product SET status = 1 WHERE product_id = '" . $this->db->escape($result['product_id']) . "' AND quantity > 0");
$this->db->query("UPDATE " . DB_PREFIX . "relatedoptions SET quantity = 0 WHERE product_id = '" . $this->db->escape($result['product_id']) . "' AND store_stock = 0");
}
return $result;
}
Need help. And fast.
Take care,
Shawn