X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (X-Cart 5) (https://forum.x-cart.com/forumdisplay.php?f=56)
-   -   Sorting products by 'Position' (https://forum.x-cart.com/showthread.php?t=76853)

welly 03-03-2019 11:23 AM

Sorting products by 'Position'
 
Hi all

On the customer side, I want to be able to sort my products in each category according to their 'position' field just as I do in my 4.x store, but that particular sort option doesn't exist.

I can see that there is a developer doc which explains how to add a sort option (their example is 'arrivalDate'), and I'm happy to follow that doc having used a couple of others with some success, but instead of 'p.arrivalDate' what should I be using?

Would 'p.pos' be too easy?

On a similar note, how do I find out what the structure of the product data model/entity is so that in future I can just refer to that? Or any model, in fact?

Many thanks

Welly

cflsystems 03-03-2019 05:54 PM

Re: Sorting products by 'Position'
 
Don't do search for products within category. Go to the categories list and click on the product number or go to the category you want to do the sort for and click on the product tab.
This will give you a list of product assigned to the category.
If you have more than X products the position field is text field to enter number into. If you have less than X products there is no text field for position - instead there is a drag/drop icon - just drag the products to change the order. X is the number of products to show on one page.

welly 03-04-2019 12:25 AM

Re: Sorting products by 'Position'
 
Hi Steve

I'm not sure I understand.

I'm asking about adding a sort criterion to the category products on the customer side using an existing product field. I can follow the relevant developer doc which uses the example 'p.arrivalDate', but I don't know how to reference the field I want. The position field.

More importantly, I don't know how to find out what fields are available for products (or categories, or anything at all).

Can you help with that?

Many thanks

Welly

cflsystems 03-04-2019 05:20 PM

Re: Sorting products by 'Position'
 
You do not have to add anything. It is already there. And it will sort by position. But you need to set this position in admin - see my previous post.

Now if you are talking about allowing customers to sort by position - that's something else. But I don't really understand why customers will care about this. The position field is more of an internal thing than public.
Anyway you can still do that but you need to make changes to how products show and the sort by dropdown filter. The field I believe is called position but check ./Model/Product.php to be sure.

david_ygao 05-01-2019 04:54 PM

Re: Sorting products by 'Position'
 
Sorting products by SKU is very useful for customer to find similar products, since similar products have similar SKU numbers. Unfortunately XC5 has removed this XC4 feature. Is it easy to add such feature ? We have very long list product in each category, It is almost impossible to manage to sort many products by pos in admin manually (by SKU in my case).

welly 05-02-2019 12:29 AM

Re: Sorting products by 'Position'
 
Adding a sort option is described in this document:

https://devs.x-cart.com/basics/itemslist_introduction_--_showing_products_on_a_page/adding_new_sort_by_opt...itemslist.html

The example uses a date, but if you can identify the SKU field, you should be able to use that. Unfortunately, this is where I came unstuck, but as Steve said in his last post, the option I wanted was already there. I just didn't know it at the time.

Welly


All times are GMT -8. The time now is 12:15 PM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.