nop 4.4.0.3 Product Category Mapping Display Order Unexpected Behaviour

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 anni tempo fa
Hello,

The Product_Category_Mapping table has a DisplayOrder column that should be used when selecting sort by 'Position' within a category.  Instead, the Product's DisplayOrder value is being used (default behaviour) within the ProductExtensions static class.

The Admin\Category\Edit\Products tab behaves correctly and displays the products in the order assigned to the DisplayOrder field.  This assigned DisplayOrder is expected when viewing the Category and its Product(s).

Therefore, a solution would be to have 'Sort By' enum values for sorting by Product DisplayOrder and Product_Category_Mapping DisplayOrder.  Alternatively, the 'Position' enum should be used to sort by Product_Category_Mapping DisplayOrder only.  The ProductExtension class only extends the Product object and the Product_Category_Mapping DisplayOrder is not available.  

The problem is with the 'join' on the tables, the approaches are different and result in different as can be viewed below:

ProductService::public virtual async Task<IPagedList<Product>> SearchProductsAsync(...

Select
         ...
  [p].[ParentGroupedProductId],
  [p].[ProductTypeId]
FROM
  [Product] [p]
WHERE
  [p].[Published] = 1 AND [p].[Deleted] = 0 AND EXISTS(
    SELECT
      *
    FROM
      [Product_Category_Mapping] [pc]
    WHERE
      [pc].[IsFeaturedProduct] = 0 AND [pc].[CategoryId] IN (2763) AND
      [pc].[ProductId] = [p].[Id]
  )

and CategoryService::public virtual async Task<IPagedList<ProductCategory>> GetProductCategoriesByCategoryIdAsync...

SELECT
  [pc].[Id],
  [pc].[DisplayOrder],
  [pc].[IsFeaturedProduct],
  [pc].[CategoryId],
  [pc].[ProductId]
FROM
  [Product_Category_Mapping] [pc]
    INNER JOIN [Product] [p] ON [pc].[ProductId] = [p].[Id]
WHERE
  [pc].[CategoryId] = @categoryId AND [p].[Deleted] = 0
ORDER BY
  [pc].[DisplayOrder],
  [pc].[Id]

Reproduce the steps by assigning all Products a DisplayOrder of 0 (zero).  Within Admin Area, edit a Category, add Products and assign positve DisplayOrder numbers.  The Products will be sorted correctly in the Admin Category.  Clear Cache\Restart App.  Preview category and confirm products not in expected assigned order.

Kind regards,
2 anni tempo fa
Thanks for pointing out this bug. We'll fix it.
2 anni tempo fa
Hi, webie, thank you for your report, I spotted this yesterday and was trying to find out why this was happening, is there a fix I can do now before NOP 4.5 update?
2 anni tempo fa
phayes wrote:
Hi, webie, thank you for your report, I spotted this yesterday and was trying to find out why this was happening, is there a fix I can do now before NOP 4.5 update?


Hi
I have been looking at this too and I found out that Nop uses a static method
OrderBy 
at
ProductExtensions 
class to sort the products and it uses product table's displayorder column rather than product_category_mapping table's displayorder  column.
I think the OrderBy method needs to be rewritten so that if there are categoryid or manufacturerIds parameter in the product's search method then the products need to be sorted using the mapping's class display order
2 anni tempo fa
Related? https://github.com/nopSolutions/nopCommerce/issues/5650
2 anni tempo fa
yes, it's related, but it looks like the update will not be published until v4.5, this feature is key on our site and much needed.
2 anni tempo fa
phayes wrote:
yes, it's related, but it looks like the update will not be published until v4.5, this feature is key on our site and much needed.


I would imagine (hope), that a fix would come along as a minor release?
2 anni tempo fa
I hope so.

If the NOP team see this message, please understand the order by position feature grabs a visitors attention by showing selected products when they first visit a category page, if it does not do this and shows random products then the visitor may leave. It's a very good marketing tool, so it should be fixed in a minor update and not a major one.
2 anni tempo fa
Postion has performed very well in the previous version.

In this version 4.4, the order by "position" on the demo page https://frontend.nopcommerce.com/ also works incorrectly.



2 anni tempo fa
phayes wrote:
I hope so.

If the NOP team see this message, please understand the order by position feature grabs a visitors attention by showing selected products when they first visit a category page, if it does not do this and shows random products then the visitor may leave. It's a very good marketing tool, so it should be fixed in a minor update and not a major one.


It would be very disappointing to have to wait until the next major release (April 22?) for an official fix to this implementation of product sorting within categories.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.