Recently Viewed Products

You need to login to post comments.

Jerry PetsFantastic
2 years ago
Hi Maxter, I'm working on setting up a new E commerce website using AbanteCart V1.2.9. I've also purchased your Recently Viewed Products extension V1.0.0, which has been working flawlessly until now. During testing the AbanteCart website, pressing the View link, to view the details of a certain product, I got the message: "product not found", and no product details were displayed.
When I clicked the View link again for another product, the following SQL Error was displayed:
Error No: 1064
SQL: SELECT *
FROM abc_products p
LEFT JOIN abc_product_descriptions pd ON (p.product_id = pd.product_id AND pd.language_id = '1')
LEFT JOIN abc_products_to_stores p2s ON (p.product_id = p2s.product_id)
WHERE p2s.store_id = '0'
AND p.product_id IN (105, , 78)
AND p.status='1'
AND p.date_available /var/www/html/abante-129/core/database/amysqli.php on line 108
Apparently, because of the AbanteCart error: "product not found", an empty product_id was stored in the collection of viewed product id's, leading to the incorrect SQL statement . . . AND p.product_id IN (105, , 78)

The "product not found" is not an error of your Recently Viewed Products extension, but because of storing the empty product_id in your session list of viewed products, the above incorrect SQL statement is generated in your extension.
I've had a look at the source code of your extension, and came up with the following solution in the Storefront ControllerViewedProductsViewedProducts, line 48, and changed it as below:
if (($result == $this->request->get['product_id']) || empty($result)) {
unset . . . .
}
Can you please look into this and let me know, whether this would be sufficient to prevent storing and using empty product_id's of viewed products, during any given session? Or maybe you have a better solution?


Thanks a lot.
Cheers
Jerry, Australia.

maxter
2 years ago
Yes, you are right. This is a correct fix with extra check to avoid strings:

foreach ($product_ids as $index => $result) {
//skip current product
if ($result == $this->request->get['product_id'] || empty($result) || !is_numeric($result)) {
unset($product_ids[$index]);
}
}


I will upload updated package shortly.
Thank you for detailed explanation!
Jerry PetsFantastic
2 years ago
Thank you, Maxter. I've tested the final solution, and it works. Great!
rahul valani
2 years ago
Hi I am using this viewed Products extension and it was working fine untill I upgraded my version to 1.2.8 now it throws me error "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 621, 633) AND customer_group_id = '1' AND ((date_start = '0000-00' at line 3 in /home/amer/public_html/live_128/core/database/apdomysql.php on line 54" and takes me to static_pages/index.php And if I turn off this extension it work fine I get this error when the site is loaded for first time and I click on any product
I tried edit your controller at line 145 with private function getProductsfromIDs($products) {
if (!$products) {
return array();
}
foreach ($products as $k => $v){
if($v == ""){
unset($products[$k]);
}
}
But still it is not working and throwing me error
Can you guys please help me?

maxter
2 years ago
I wonder why you now get a syntax error in SQL. There is no such SQL in this extension. Look like SQL cut off at the end. This probably issues with the upgrade in some core file.

This can be in getProductsAllInfo() function in storefront/model/catalog/product.php
rahul valani
2 years ago
Hi I am using this viewed Products extension and it was working fine untill I upgraded my version to 1.2.8 now it throws me error "SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' 621, 633) AND customer_group_id = '1' AND ((date_start = '0000-00' at line 3 in /home/amer/public_html/live_128/core/database/apdomysql.php on line 54" and takes me to static_pages/index.php And if I turn off this extension it work fine I get this error when the site is loaded for first time and I click on any product

Single Installation License

$15.00

Single installation, is for use by single site or one copy of application using this extension

maxter   

   Viewed 13572 times

   Posted 6 comments

   Details

Extension ID: viewed_products
Extension Latest Version: 1.0.1
AbanteCart Version: 1.2, 1.2.0, 1.2.1, 1.2.2, 1.2.3, 1.2.4, 1.2.5, 1.2.6, 1.2.7, 1.2.8, 1.2.9, 1.2.10, 1.2.11, 1.2.12, 1.2.13, 1.2.14
Created: Dec 29, 2014
Last updated: Jan 12, 2018