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)
-   -   New Sort By Option (https://forum.x-cart.com/showthread.php?t=78285)

LTucker 08-17-2021 02:30 PM

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

pauldodman 08-18-2021 01:29 AM

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.

LTucker 08-18-2021 11:18 AM

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...

cflsystems 08-18-2021 04:35 PM

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.

Ed B. 08-30-2022 01:12 AM

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 ?

Ed B. 08-31-2022 11:13 PM

Re: New Sort By Option
 
Actually I was a bit hasty. The module simply works.


All times are GMT -8. The time now is 12:12 PM.

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