Reputation: 445
When navigating in product categories, products are randomly sorted instead of being sorted by position.
You can see the bug by refreshing this page several time:
http://www.jollia.fr/collection-bijoux.html
You will see different products each time.
I have not made any change to the Product Category controllers. I have tried to reindex product and category data and empty cache. But nothing fixes this issue.
Upvotes: 0
Views: 1032
Reputation:
This cannot be debugged without access to the code. It could be any thing, from bad extension to bad code. I personally have seen all kinds of bad practices by so-called Magento developers who make no attempt to understand Magento at all and think they can do any thing. As a last resort, their bad code can usually be found in the template (for category lists, in app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/catalog/product/list.phtml). The handiwork of a bad Magento developer can usually be found in the template.
If not, inspect the sql of the product collection loaded by this block (Mage_Catalog_Block_Product_List). At the top of app/design/frontend/[YOUR_PACKAGE]/[YOUR_THEME]/template/catalog/product/list.phtml, print out the SQL of the collection:
$_productCollection=$this->getLoadedProductCollection();
$selectStr = (string)$_productCollection->getSelect();
var_dump($selectStr);
The SQL should look some thing like the following:
SELECT `e`.*, `cat_index`.`position` AS `cat_index_position`, `price_index`.`price`, `price_index`.`tax_class_id`, `price_index`.`final_price`, IF(price_index.tier_price IS NOT NULL, LEAST(price_index.min_price, price_index.tier_price), price_index.min_price) AS `minimal_price`, `price_index`.`min_price`, `price_index`.`max_price`, `price_index`.`tier_price` FROM `catalog_product_entity` AS `e`
INNER JOIN `catalog_category_product_index` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.visibility IN(2, 4) AND cat_index.category_id = '24'
INNER JOIN `catalog_product_index_price` AS `price_index` ON price_index.entity_id = e.entity_id AND price_index.website_id = '1' AND price_index.customer_group_id = 0 ORDER BY `cat_index`.`position` ASC LIMIT 12
Look at the ORDER BY clause for clues. If your SQL does not look some thing like the above, then may be an extension is modifying the collection. There is an event that is dispatched before the collection is loaded: catalog_block_product_list_collection. Search your extensions in the app/code/community or app/code/local codepools for "catalog_block_product_list_collection" and see if any extensions are observing this event and modifying this collection.
The block could also have been rewritten; search the app/code/community and local codepools for:
extends Mage_Catalog_Block_Product_List
I personally have seen all kinds of shortcuts taken by developers who either don't know any better or just don't care.
Upvotes: 1
Reputation: 552
To sort the products by position you have to manually enter order to each product in a category, Admin > Catalog > Manage Categories... Select your category and goto Category Products tab. See the image below.
Upvotes: 0