Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Items List sort on a Product Attribute

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-26-2017, 03:29 PM
 
sysp2 sysp2 is offline
    
Join Date: Dec 2016
Posts: 1
 

Default Items List sort on a Product Attribute

I have gone through the doc on creating a new sort:
http://devs.x-cart.com/en/basics/itemslist_introduction_--_showing_products_on_a_page/adding_new_sort_by_option_to_itemslist.html
I can successfully adjust this for stock level with p.amount. I was not able to come up with the correct method to do this for a product attribute. Is this possible?
Thank you
__________________
sysp
Reply With Quote
  #2  
Old 02-26-2017, 11:16 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Items List sort on a Product Attribute

This will be trickier as attributes are a separate table that is not always linked (the "linkInner" and "linkLeft" methods) with the products table when querying the data.

If tables are not linked, you have to decorate the \XLite\Model\Repo\Product:: getQueryBuilderForSearch() method and link the tables manually. When calling linkInner() and linkLeft() methods, the second parameter is the alias that you should use to reference fields in that table. Please check the \XLite\Model\Repo\Order::getQueryBuilderForSearch( ) method for an example of linking extra tables.

Another thing is that you need to determine the identifier of the attribute that you want to order products by.
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 08:19 AM.

   

 
X-Cart forums © 2001-2020