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

Sorting by Products by SKU
 
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 03-22-2016, 09:28 PM
 
iallouise iallouise is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 8
 

Default Sorting by Products by SKU

Hello I managed to make it work on my localhost.
1.) Option for SKU sort
2.) Auto sort all by sku alpha

using idecorator here's the code

public function __construct(array $params = array())
{
parent::__construct($params);

$this->sortByModes = array(
'p.sku' => 'Part Number',
) + $this->sortByModes;
}

/**
* getSortByModeDefault
*
* @return string
*/
protected function getSortByModeDefault()
{
return static::SORT_BY_MODE_SKU;
}


It's working in my localhost but it doesn't in my live site....

maybe because my localhost has older modules than my live site?

I have Simple CMS 5.2.12 in localhost
and Simple CMS 5.2.14 in live site

Could this be causing it not to work, I even changed the core file to SORT_BY_MODE_SKU to testbut same outcome not working
__________________
X-Cart
Business 5.2.13
Reply With Quote
  #2  
Old 03-22-2016, 10:22 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

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

Default Re: Sorting by Products by SKU

Every class extended from \XLite\View\ItemsList\AItemsList class has the getSortByModeDefault() method, but the SORT_BY_MODE_SKU constant is declared in \XLite\View\ItemsList\Model\Product class, so if you want to use this constant, your class must has the Product class in its inheritance tree.

What class do you use this constant in?
__________________
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

The following user thanks qualiteam for this useful post:
iallouise (03-23-2016)
  #3  
Old 03-23-2016, 01:13 AM
 
iallouise iallouise is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 8
 

Default Re: Sorting by Products by SKU

Im sorry it's working now my error was

in my live site my code is

+ + $this->sortByModes;

it should be

+ $this->sortByModes;

Thanks anyways for the tips sir! cheers~!
__________________
X-Cart
Business 5.2.13
Reply With Quote
  #4  
Old 03-23-2016, 07:00 PM
 
iallouise iallouise is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 8
 

Default Re: Sorting by Products by SKU

Im sorry my bad can I revive this post? The only one that's working is the first functionality to add new sort option.. The automatic sort is not working...

I used the SORT_BY_MODE_SKU in \XLite\View\ItemsList\Product\Customer\ACustomer Class. In the core file > function getSortByFields I noticed the constant is there so i assumed it can be used as a default in getSortByModeDefault()

How can I inherit it in my class?
__________________
X-Cart
Business 5.2.13
Reply With Quote
  #5  
Old 05-13-2019, 08:38 PM
 
david_ygao david_ygao is offline
 

Advanced Member
  
Join Date: Feb 2005
Location: canada
Posts: 38
 

Default Re: Sorting by Products by SKU

Quote:
Originally Posted by iallouise
Im sorry my bad can I revive this post? The only one that's working is the first functionality to add new sort option.. The automatic sort is not working...

I used the SORT_BY_MODE_SKU in \XLite\View\ItemsList\Product\Customer\ACustomer Class. In the core file > function getSortByFields I noticed the constant is there so i assumed it can be used as a default in getSortByModeDefault()

How can I inherit it in my class?

Have you figured out how to make "automatic sort" (recommended default sort) working ?
__________________
/David Gao/
X-cart business 5.3.6
Reply With Quote
  #6  
Old 05-16-2019, 05:59 AM
  seyfin's Avatar 
seyfin seyfin is offline
 

X-Cart team
  
Join Date: May 2004
Posts: 1,223
 

Default Re: Sorting by Products by SKU

Please find a sample module "SortingBySKU" attached.
Attached Files
File Type: tar XCExample-SortingBySKU-v5_3_0.tar (19.5 KB, 13 views)
__________________
Sincerely yours,
Sergey Fomin
X-Cart team
Chief support group engineer

===

Check this out. Totally revamped X-Cart hosting
http://www.x-cart.com/hosting.html

Follow us:
https://twitter.com/x_cart / https://www.facebook.com/xcart / https://www.instagram.com/xcart
Reply With Quote
  #7  
Old 05-17-2019, 12:02 PM
 
david_ygao david_ygao is offline
 

Advanced Member
  
Join Date: Feb 2005
Location: canada
Posts: 38
 

Default Re: Sorting by Products by SKU

Quote:
Originally Posted by seyfin
Please find a sample module "SortingBySKU" attached.
It is working well. Many thanks,
__________________
/David Gao/
X-cart business 5.3.6
Reply With Quote
Reply
   X-Cart forums > X-Cart 5 > Modifying the design and features (X-Cart 5)


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 07:47 PM.

   

 
X-Cart forums © 2001-2018