Post by MatthewB » Mon Sep 12, 2011 12:06 am

Hi

i have noticed that some products are duplicating on my website, for example i have a photo frame under "gifts for children" on page 1 then when i go to page 2 the same product is on that page further down the product list, the same is happening for a few products

i have checked "links" in backoffice and i only have that category selected, does anyone have a clue?
Last edited by i2Paq on Tue Nov 08, 2011 2:37 am, edited 1 time in total.
Reason: Title adjusted, moved

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by uksitebuilder » Mon Sep 12, 2011 9:08 pm

it is due to the ordering of products.

by default the order the products are returned from the database is by sort order.

Many people will not enter this when editing/adding a product and so essentially every product has the same sort order.

When page 2 is clicked in the product list, the query is run again and consequently returns different results.

This fix may work,

in catalog/model/catalog/product.php

find:

Code: Select all

$sql .= " ORDER BY p.sort_order";
change to:

Code: Select all

$sql .= " ORDER BY p.sort_order ASC p.product_id";
catalog/controller/catalog/category.php

find

Code: Select all

$sort = 'p.sort_order';
change to

Code: Select all

$sort = 'p.sort_order ASC p.product_id';
You may need to repeat the last change above in search.php, manufacturer.php and special.php

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by MatthewB » Tue Sep 13, 2011 1:34 am

Hi Simon

Thank you so much, you've saved the day yet again, i've lost count how much you've helped me with my sites haha

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by MatthewB » Wed Sep 14, 2011 6:27 pm

For some reason the problem is back again.

I've not done anything other than add more products.

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by uksitebuilder » Wed Sep 14, 2011 6:49 pm

Check the file still has those changes in my post above

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by MatthewB » Wed Sep 14, 2011 6:57 pm

uksitebuilder wrote:Check the file still has those changes in my post above
Hi

i've checked and file still has code change, it is working on some products but i've noticed there is still a few that appear on different pages of the same category

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by aledmann » Tue Nov 01, 2011 3:00 am

Did you ever get to the bottom of this? I'm having the exact same problem!! ???

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm

Post by MatthewB » Tue Nov 01, 2011 3:31 am

The above coding seemed to work, i also changed the "number of products displayed" in admin

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by aledmann » Tue Nov 01, 2011 3:59 am

Damn really? That code didn't work for me. I'm running 1.5.1.1

I really have too many products to go back and sort order them all. I can't really see this being feasible moving forward either.

Has anyone got a recommended fix for this? We were hoping to launch our site this week and only found this glaringly obvious bug today!!

Thank you in advance.

User avatar
New member

Posts

Joined
Thu Sep 08, 2011 9:56 pm

Post by uksitebuilder » Tue Nov 01, 2011 4:29 am

edited my post above

User avatar
Guru Member

Posts

Joined
Thu Jun 09, 2011 11:37 pm
Location - United Kindgom

Post by MatthewB » Tue Nov 01, 2011 5:31 am

aledmann wrote:I really have too many products to go back and sort order them all. I can't really see this being feasible moving forward either.
All you have to do is in admin settings/edit/option then type a high number for number of product displayed on page.

for mine i typed 10 as i don't have more than ten products per page in each categories

Matthew


Active Member

Posts

Joined
Sat Jul 23, 2011 5:18 am
Location - Sunderland Tyne and Wear

Post by AnonyMoose » Sat Nov 05, 2011 2:50 am

uksitebuilder wrote: in catalog/model/catalog/product.php

find:

Code: Select all

$sql .= " ORDER BY p.sort_order";
change to:

Code: Select all

$sql .= " ORDER BY p.sort_order ASC p.product_id";

This kind of fixed my sorting issues, but after few page reloads it repeats again..
uksitebuilder wrote: catalog/controller/catalog/category.php

find

Code: Select all

$sort = 'p.sort_order';
change to

Code: Select all

$sort = 'p.sort_order ASC p.product_id';
You may need to repeat the last change above in search.php, manufacturer.php and special.php
Did you mean catalog/controller/product/category.php ? Done this part and got this error when browsing to any category:

Code: Select all

Notice: Error: 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 'p.product_id ASC LIMIT 0,15' at line 1
Error No: 1064
SELECT p.product_id, (SELECT AVG(rating) AS total FROM review r1 WHERE r1.product_id = p.product_id AND r1.status = '1' GROUP BY r1.product_id) AS rating FROM product p LEFT JOIN product_description pd ON (p.product_id = pd.product_id) LEFT JOIN product_to_store p2s ON (p.product_id = p2s.product_id) LEFT JOIN product_to_category p2c ON (p.product_id = p2c.product_id) WHERE pd.language_id = '1' AND p.status = '1' AND p.date_available <= NOW() AND p2s.store_id = '0' AND p2c.category_id = '66' GROUP BY p.product_id ORDER BY p.sort_order ASC p.product_id ASC LIMIT 0,15 in /home/seventea/public_html/system/database/mysql.php on line 49

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by AnonyMoose » Sat Nov 05, 2011 2:56 am

Just a thought:

$sql .= " ORDER BY p.sort_order"; appears twice in catalog/model/catalog/product.php, so I changed both entries..

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by AnonyMoose » Mon Nov 07, 2011 11:27 pm

Tried again - changed both $sql .= " ORDER BY p.sort_order" entries in catalog/model/catalog/product.php and $sort = 'p.sort_order'; in catalog/controller/product/category.php (my guess as catalog/controller/catalog/category.php doesn't exist).

Still got those SQL errors in random categories, so no joy. This fix also $#@%&( up google base product feed - got SQL error too.. :( Any suggestions or signs of fixing this in 1.3.1.4?

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by i2Paq » Tue Nov 08, 2011 2:38 am

I think that the sort-order field when entering a product should be mandatory.

Or a fix in the code preventing this from happening.

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by AnonyMoose » Tue Nov 08, 2011 3:39 am

i2Paq wrote:I think that the sort-order field when entering a product should be mandatory.

Or a fix in the code preventing this from happening.

And if I have 852 products, remove three in the middle and then want to add one, remove few more and add some tomorrow, will you re-edit sort order on all of them for me please? :-)

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by i2Paq » Tue Nov 08, 2011 3:54 am

AnonyMoose wrote:will you re-edit sort order on all of them for me please? :-)
Sure ;D

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by AnonyMoose » Tue Nov 08, 2011 4:45 am

i2Paq wrote:
AnonyMoose wrote:will you re-edit sort order on all of them for me please? :-)
Sure ;D

Got screenshot, you have no excuses now! ;P

New member

Posts

Joined
Wed Jul 20, 2011 5:35 pm

Post by i2Paq » Tue Nov 08, 2011 3:25 pm

AnonyMoose wrote:
i2Paq wrote:
AnonyMoose wrote:will you re-edit sort order on all of them for me please? :-)
Sure ;D
Got screenshot, you have no excuses now! ;P
I wonder who banned you Image

Norman in 't Veldt
Moderator OpenCart Forums

_________________ READ and Search BEFORE POSTING _________________

Our FREE search: Find your answer FAST!.

[How to] BTW + Verzend + betaal setup.


User avatar
Global Moderator

Posts

Joined
Mon Nov 09, 2009 7:00 pm
Location - Winkel - The Netherlands

Post by jhebb » Fri Dec 30, 2011 11:29 pm

Was there any fix for the code changes suggested? I was getting the same SQL error too.

New member

Posts

Joined
Tue Oct 18, 2011 7:32 am
Who is online

Users browsing this forum: No registered users and 14 guests