Page 1 of 1

[OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 3:46 am
by MaximumLife
Hi,
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;
}
The problem, however, is that the products that are NOT on the CSV file do not disable. Also quantities SET in Related Options do not transfer over (total calculated) to the options' settings in OpenCart.

Need help. And fast.

Take care,
Shawn

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 3:53 am
by paulfeakins
Feel free to drop us an email for a quick estimate: info@antropy.co.uk

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 5:35 am
by JAY6390
Hi Shawn

So if I'm understanding correctly, you want to disable any products not in the CSV after you've updated all the items that are?
You also want to put quantities into standard options as well as related options?

Kind regards
Jay

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 8:31 am
by MaximumLife
JAY6390 wrote:
Fri Oct 27, 2023 5:35 am
Hi Shawn

So if I'm understanding correctly, you want to disable any products not in the CSV after you've updated all the items that are?
You also want to put quantities into standard options as well as related options?

Kind regards
Jay
Yes, you are right, my friend! Yes, after updating related options, the data should be transferred to Opencart options!

Take care,
Shawn

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 9:45 am
by MaximumLife
This was my final result for function getProductByModel

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 = 1 WHERE product_id = '" . $this->db->escape($result['product_id']) . "' AND quantity > 0");

}
I also changed another function, function updateProductStatus

Code: Select all

public function updateProductStatus($products, $manufacturers, $filename){
	
if (count($products) > 0){

$this->db->query("UPDATE " . DB_PREFIX . "product SET status = 1 WHERE quantity > 0 AND manufacturer_id IN (" . implode(',', $manufacturers) . ") AND product_id IN (" . implode(',', $products) . ")");

} else {

$this->db->query("UPDATE " . DB_PREFIX . "product SET status = 0 WHERE manufacturer_id IN (" . implode(',', $manufacturers) . ") AND product_id NOT IN (" . implode(',', $products) . ")");	

}
	
}

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 11:30 am
by MaximumLife
Still looking for help to go...

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 3:45 pm
by SohBH
Are you looking for disable all products before importing CSV files for updating product information?
You can email me to discuss this further.

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 7:32 pm
by paulfeakins
MaximumLife wrote:
Fri Oct 27, 2023 11:30 am
Still looking for help to go...
Paid help or free help? Because this is the Commercial Support forum ...

Re: [OC-2.3.0.2][Ext=RelatedOptions] Import Tool Not Working as Expected

Posted: Fri Oct 27, 2023 8:18 pm
by MaximumLife
Honestly, I'm looking for a long-time partner.

I was able to solve the problem I had on my own using the code previously mentioned.

If anyone wants to be my partner for the long-term please let me know. I am now in contact with Paul and plan on using him in the future for bigger projects.