Post by MaximumLife » Fri Oct 27, 2023 3:46 am

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

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm

Post by paulfeakins » Fri Oct 27, 2023 3:53 am

Feel free to drop us an email for a quick estimate: info@antropy.co.uk

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by JAY6390 » 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

Image


User avatar
Guru Member

Posts

Joined
Wed May 26, 2010 11:47 pm
Location - United Kingdom

Post by MaximumLife » Fri Oct 27, 2023 8:31 am

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

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm

Post by MaximumLife » Fri Oct 27, 2023 9:45 am

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) . ")");	

}
	
}
Last edited by MaximumLife on Fri Oct 27, 2023 6:52 pm, edited 1 time in total.

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm

Post by MaximumLife » Fri Oct 27, 2023 11:30 am

Still looking for help to go...

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm

Post by SohBH » Fri Oct 27, 2023 3:45 pm

Are you looking for disable all products before importing CSV files for updating product information?
You can email me to discuss this further.

View all extensions | Request custom work | Pricing | Contact Me


User avatar
Active Member
Online

Posts

Joined
Mon Nov 02, 2020 12:01 am
Location - Malaysia

Post by paulfeakins » Fri Oct 27, 2023 7:32 pm

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 ...

UK OpenCart Hosting | OpenCart Audits | OpenCart Support - please email info@antropy.co.uk


User avatar
Legendary Member
Online

Posts

Joined
Mon Aug 22, 2011 11:01 pm
Location - London Gatwick, United Kingdom

Post by MaximumLife » Fri Oct 27, 2023 8:18 pm

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.

Life Is A Journey. Enjoy It :)


New member

Posts

Joined
Sun Oct 16, 2022 10:17 pm
Who is online

Users browsing this forum: paulfeakins, SohBH and 4 guests