![]() |
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 |
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. |
All times are GMT -8. The time now is 01:31 PM. |
Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.