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 by Products by SKU (https://forum.x-cart.com/showthread.php?t=73756)

iallouise 03-22-2016 09:28 PM

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 :(

qualiteam 03-22-2016 10:22 PM

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?

iallouise 03-23-2016 01:13 AM

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! :D cheers~!

iallouise 03-23-2016 07:00 PM

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?

david_ygao 05-13-2019 08:38 PM

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 ?

seyfin 05-16-2019 05:59 AM

Re: Sorting by Products by SKU
 
1 Attachment(s)
Please find a sample module "SortingBySKU" attached.

david_ygao 05-17-2019 12:02 PM

Re: Sorting by Products by SKU
 
Quote:

Originally Posted by seyfin
Please find a sample module "SortingBySKU" attached.

It is working well. Many thanks,


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

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