Display per page not being preserved

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
5 years ago
Hi,

When I go to a category and change the default display per page from 6 to 9 and then click another category 9 is not preserved and have to select it again every time I change category.

Same problem for Sort by

Is there any way to preserve them?

Thanks in advance
5 years ago
You can check,
1.  Categories> edit Category.  "Page Size Options" list you selection here.  example: 32,27,24.
> I put 32 first because that is what I want the default to be.  If I list 8,32,27,24, then the page defaults to 8.
5 years ago
pantonis wrote:
Hi,

When I go to a category and change the default display per page from 6 to 9 and then click another category 9 is not preserved and have to select it again every time I change category.

Same problem for Sort by

Is there any way to preserve them?

Thanks in advance


No. NopCommerce does not provides something out of box to preserve these. But, with a little customization, this can be achieved easily.

You can save last selected value in database, similar to when you select a store from multi-store drop-down in admin site under settings. NopCommerce saves last selected store in database and automatically loads it next time when you go to any other page where multi-store drop-down is available.

Hope this would help.

Regard's,
Atul
5 years ago
For Sort, Check

Configuration> Settings > Catalog Settings

Go to Product sorting (at the bottom).
Here you must set priority on sorting.


Example:  I want to rank the first 4 products to always appear at the top of the page, but after that I want to the rest of the products to fill in A-Z.  So I set "Position" "display Order" 1, and A-z Display Order 2.
5 years ago
nopAdvance wrote:
Hi,

When I go to a category and change the default display per page from 6 to 9 and then click another category 9 is not preserved and have to select it again every time I change category.

Same problem for Sort by

Is there any way to preserve them?

Thanks in advance

No. NopCommerce does not provides something out of box to preserve these. But, with a little customization, this can be achieved easily.

You can save last selected value in database, similar to when you select a store from multi-store drop-down in admin site under settings. NopCommerce saves last selected store in database and automatically loads it next time when you go to any other page where multi-store drop-down is available.

Hope this would help.

Regard's,
Atul



Can you suggest another setting that it use db to save it rather than the one with the multistore.
5 years ago
Hi,

Yes. NopCommerce uses similar technique at other places too such as, on admin dashboard you can see different collapsible panes. When you collapse a pane and go back to dashboard again, nopCommerce remembers that you have collapsed / not collapsed a pane and displays it accordingly.

You can see it in below explanation on how it works for panes. Let's talk about news pane:

Go to this page in code: \Presentation\Nop.Web\Areas\Admin\Views\Shared\Components\NopCommerceNews\Default.cshtml

At line number 8, 9 and 10 you can see following code which reads current setting for a pane from database:

const string panelId = "nopcommerce-news-box";
const string hidePanelAttributeName = "HideNopCommerceNewsPanel";
var hidePanel = genericAttributeService.GetAttribute<bool>(workContext.CurrentCustomer, hidePanelAttributeName);


Now, at line number 13 you can see following code that set's css property based on condition:

<div class="box box-info @if(hidePanel){<text>collapsed-box</text>}" id="@panelId">


I hope this gives you a proper answer on how you can achieve what you asked using some tweaks in your code. Let me know if you have any more queries regarding this.

Thank you,
Atul
5 years ago
Thanks for your reply.

How do I call the following

genericAttributeService.SaveAttribute<int>(workContext.CurrentCustomer, selectedGridPageSize, 6);


on

 @Html.DropDownList("products-pagesize", Model.PageSizeOptions, new { @class = "form-control custom-select", onchange = "setLocation(this.value);", aria_label = T("Catalog.PageSize.Label") })

onchange event?
5 years ago
Hi,

Please look at complete implementation on above suggested page. You will get an idea on how to implement something that you are looking for.

Best regard's,
Atul
5 years ago
I implemented it using your suggestion with generic attributes but in a different way. Changed some code into CatalogModelFactory. Dont understand why this is not part of the core functionality. Very very bad UX without this feature.

Thanks for all your help
5 years ago
pantonis wrote:
I implemented it using your suggestion with generic attributes but in a different way. Changed some code into CatalogModelFactory. Dont understand why this is not part of the core functionality. Very very bad UX without this feature.

Thanks for all your help


That's great. Can you please share your solution here, so everyone in community will get it when needed?

Regards,
Atul
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.