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

New Sort By Option

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 08-17-2021, 02:30 PM
 
LTucker LTucker is offline
 

Member
  
Join Date: Mar 2020
Posts: 14
 

Default New Sort By Option

I'm working on adding a new sort by option, amount/ stock level. I've tried following the X-Cart Documentation Adding New Sort Option to ItemList and have not had any success. Is this task completed differently for post 5.3 versions?

Thank you
__________________
Larry Tucker
Programmer Analyst, WPG Americas Inc.

X-Cart v5.4.0.1 [Linux]
Reply With Quote
  #2  
Old 08-18-2021, 01:29 AM
  pauldodman's Avatar 
pauldodman pauldodman is offline
 

X-Guru
  
Join Date: Jul 2003
Location: Spain / UK
Posts: 3,060
 

Default Re: New Sort By Option

Probably - it looks like that documentation is for 5.3.
This is often the case - 5.4 is quite a bit different so a lot of these pages are out of date now.
__________________
Paul Dodman
e-business & m-commerce consultant
w: www.luminointernet.com
e: xcart@luminointernet.com

Professional X-Cart help, advice, support and services, specialists in Mobile X-Cart.
Reply With Quote
  #3  
Old 08-18-2021, 11:18 AM
 
LTucker LTucker is offline
 

Member
  
Join Date: Mar 2020
Posts: 14
 

Default Re: New Sort By Option

Yeah I've been noticing the documentation is outdated. I've also noticed a lack of standardization within the CDev and XC modules as well... which makes it difficult to understand how certain tasks are completed within this platform.

That's part of the reason why I'm reaching out here. As decorating View classes in X-Cart v5.4 or later seems to be an elusive task...
__________________
Larry Tucker
Programmer Analyst, WPG Americas Inc.

X-Cart v5.4.0.1 [Linux]
Reply With Quote
  #4  
Old 08-18-2021, 04:35 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,197
 

Default Re: New Sort By Option

Your best bet to learn how something is supposed to be done/work is to study the code within the version you are using.
The XC docs are either out of date or showing something very simple which doesn't help in most cases.
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 08-30-2022, 01:12 AM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

Default Re: New Sort By Option

Hi, this thread is kind of old, but has anyone had any luck with this ?


Here is what I have noticed on the version 5.4.35 (I am using Dewy Green theme on top of the crispy white skin, but I have checked the situation disabling Crispy White skin)


In the class XLite/View/ItemsList/Product/Customer/ACustomer.php (which is precisely what is overwritten in the module quoted in the documentation)

Code:
/** * @param array $params Widget params OPTIONAL */ public function __construct(array $params = []) { parent::__construct($params); $this->sortByModes = [ static::SORT_BY_MODE_PRICE => 'Price-sort-option', static::SORT_BY_MODE_NAME => 'Name-sort-option', ]; } /** * Get products 'sort by' fields * * @return array */ protected function getSortByFields() { return [ 'price' => static::SORT_BY_MODE_PRICE, 'name' => static::SORT_BY_MODE_NAME, 'sku' => static::SORT_BY_MODE_SKU, 'amount' => static::SORT_BY_MODE_AMOUNT, ]; }



Now, I don't have any module that could possibly show "recommended" product activated (they are, however, installed, and have been activated in the past) like featured product, best seller, cloud search. However, on my catalogue, I get "Recommended" as the default sorting order.


I searched where on earth this string could come from, the only file that could possibly be relevant is View/FormField/Select/DefaultProductSortOrder.php which contains


Code:
protected function getDefaultOptions() { return array( 'default' => static::t('Recommended'), 'priceAsc' => static::t('Price asc'), 'priceDesc' => static::t('Price desc'), 'nameAsc' => static::t('Name asc'), 'nameDesc' => static::t('Name desc'), );


Now, there is no string, priceAsc etc., that appears in any other classes. Does anyone have any idea what is going on here ?
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
Reply With Quote
  #6  
Old 08-31-2022, 11:13 PM
 
Ed B. Ed B. is offline
 

X-Adept
  
Join Date: Apr 2016
Posts: 446
 

Default Re: New Sort By Option

Actually I was a bit hasty. The module simply works.
__________________
X-cart 5.2.12, php 5.6
Ed from Grenoble, France
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 06:37 PM.

   

 
X-Cart forums © 2001-2020