Hello,
By default, products in the cart seem to be sorted by date added (The date_added field in the product table). I need the products in the cart to be sorted by model (the model field in the product table).
For the life of me, I cannot find the code that is setting the default to "date_added". If someone has the solution to this, it would be greatly appreciated!
Larry
By default, products in the cart seem to be sorted by date added (The date_added field in the product table). I need the products in the cart to be sorted by model (the model field in the product table).
For the life of me, I cannot find the code that is setting the default to "date_added". If someone has the solution to this, it would be greatly appreciated!
Larry
Last edited by glolar on Fri Feb 04, 2022 6:19 am, edited 1 time in total.
Increase Your Child's I.Q.
iPad Wallpapers
Turtle & Tortoise Screen Savers
Try to add this before "return $product_data;" in getProducts() function of system/library/cart/cart.php file:
usort($product_data, function ($a, $b) { return strcmp($a['model'], $b['model']); });
usort($product_data, function ($a, $b) { return strcmp($a['model'], $b['model']); });
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
thekrotek, that seems to have solved the issue.
I was trying to add changes to /store/catalog/controller/checkout/cart.php, and not the cart.php in /store/system/library/cart.
Cannot thank you enough!
I was trying to add changes to /store/catalog/controller/checkout/cart.php, and not the cart.php in /store/system/library/cart.
Cannot thank you enough!
Increase Your Child's I.Q.
iPad Wallpapers
Turtle & Tortoise Screen Savers
thekrotek,
Since you have been so helpful here, (and many times in the past), could I ask you a quick question? Do you know what determines which products are in the "Bestsellers" list ... Is it the products that have sold the most quantity, or is it based on total dollar amount sold for each product? I would like to look at the code that determines this, so if you know which file to look in, that would be extremely helpful.
Thanks again, thekrotek!
Larry
Since you have been so helpful here, (and many times in the past), could I ask you a quick question? Do you know what determines which products are in the "Bestsellers" list ... Is it the products that have sold the most quantity, or is it based on total dollar amount sold for each product? I would like to look at the code that determines this, so if you know which file to look in, that would be extremely helpful.
Thanks again, thekrotek!
Larry
Increase Your Child's I.Q.
iPad Wallpapers
Turtle & Tortoise Screen Savers
The first one - most purchased. The total sum of all product quantities from all orders with this product.
Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com
thekrotek,
Yeah, I found the code with the query to fetch the bestsellers. I modified it to only include products ordered in the last 120 days.
Thanks again for all the help!
Larry
Yeah, I found the code with the query to fetch the bestsellers. I modified it to only include products ordered in the last 120 days.
Thanks again for all the help!
Larry
Increase Your Child's I.Q.
iPad Wallpapers
Turtle & Tortoise Screen Savers
Larry,
Is this something you are willing to share. Also would be interested in limiting to certain product groups.
Thanks, Dan
Dan, so sorry ... I am only seeing your question two years later! Here is what I did:
In file store/catalog/model/catalog/product.php
Change this:
Code: Select all
$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit);
Code: Select all
$query = $this->db->query("SELECT op.product_id, SUM(op.quantity) AS total FROM " . DB_PREFIX . "order_product op LEFT JOIN `" . DB_PREFIX . "order` o ON (op.order_id = o.order_id) LEFT JOIN `" . DB_PREFIX . "product` p ON (op.product_id = p.product_id) LEFT JOIN " . DB_PREFIX . "product_to_store p2s ON (p.product_id = p2s.product_id) WHERE o.order_status_id > '0' AND p.status = '1' AND p.date_available <= NOW() AND o.date_added >= date(NOW() - interval 120 day) AND p2s.store_id = '" . (int)$this->config->get('config_store_id') . "' GROUP BY op.product_id ORDER BY total DESC LIMIT " . (int)$limit);
Code: Select all
AND o.date_added >= date(NOW() - interval 120 day)
Sorry again that I am just seeing your question.
Who is online
Users browsing this forum: moreduff and 265 guests