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)
-   -   Product Search (https://forum.x-cart.com/showthread.php?t=73819)

razorblade 04-07-2016 06:45 AM

Product Search
 
I think this should be a pretty straight forward modification...

I would like to know if there is a way to change the default product search from "any words" to "all words"

I'm using X-Cart Business 5.2.13

xim 04-07-2016 11:45 AM

Re: Product Search
 
cloud search will be the best solution for you: http://www.x-cart.com/extensions/addons/cloudsearch.html

it uses intelligent search

razorblade 04-07-2016 12:13 PM

Re: Product Search
 
Quote:

Originally Posted by xim
cloud search will be the best solution for you: http://www.x-cart.com/extensions/addons/cloudsearch.html

it uses intelligent search


Thank you but we had Cloud Search enabled until we hit the "free" limit. And even then the results weren't all that great.
I would much rather not pay an exorbitant monthly fee for something that should be easily tweaked out of the box.

Can you tell me how to change the default search from "any words" to "all words" ?

razortw 04-08-2016 01:33 PM

Re: Product Search
 
Hi there.
Open /classes/XLite/View/Form/Product/Search/Customer/SimpleForm.php, find this code
Code:

    protected function getDefaultParams()
    {
        return parent::getDefaultParams() + array(
            \XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING => \XLite\Model\Repo\Product::INCLUDING_ANY,
        );
    }

and replace it with
Code:

    protected function getDefaultParams()
    {
        return parent::getDefaultParams() + array(
            \XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING => \XLite\Model\Repo\Product::INCLUDING_ALL,
        );
    }

Should do the trick.
Of course, any code changes should be implemented as a module in order to keep them intact during upgrades

razorblade 04-09-2016 09:17 AM

Re: Product Search
 
Quote:

Originally Posted by razortw
Hi there.
Open /classes/XLite/View/Form/Product/Search/Customer/SimpleForm.php, find this code
Code:

    protected function getDefaultParams()
    {
        return parent::getDefaultParams() + array(
            \XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING => \XLite\Model\Repo\Product::INCLUDING_ANY,
        );
    }

and replace it with
Code:

    protected function getDefaultParams()
    {
        return parent::getDefaultParams() + array(
            \XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING => \XLite\Model\Repo\Product::INCLUDING_ALL,
        );
    }

Should do the trick.
Of course, any code changes should be implemented as a module in order to keep them intact during upgrades


That actually reminds me; I have a question about creating modules.
I have seen the instructions for creating empty modules.
Can one empty module contain any and all specific mods I make to our xcart?
Like, in one module - I have some CSS changes as well as this particular search customization?
Or do I have to create new modules for everything?
Also, how does this ensure they will be maintained during upgrades?

qualiteam 04-12-2016 09:05 PM

Re: Product Search
 
You may put as many features into a single module as you want.

However, the more complex your module is, the harder it will be for you to keep it compatible with newer X-Cart versions.
When adapting a module having a lot of features mixed in to a new X-Cart version, fixing one thing may break another one.

If you think the change that you are working on can be useful for other users/stores, it makes sense to wrap it up into its own module. You can even submit the module to our marketplace later.

BrandonLR 04-26-2016 08:49 AM

Re: Product Search
 
So how would I create a module for this specific search change function?

qualiteam 04-26-2016 11:49 PM

Re: Product Search
 
Please refer to the documentation for developers - it explains how you can create your custom modules:
http://kb.x-cart.com/

What you are to do is create a custom module that decorates the \XLite\View\Form\Product\Search\Customer\SimpleFor m class and tweaks the getDefaultParams() method as Igor advised:
https://forum.x-cart.com/showpost.php?p=395690&postcount=4

BrandonLR 04-27-2016 04:39 AM

Re: Product Search
 
Quote:

Originally Posted by qualiteam
Please refer to the documentation for developers - it explains how you can create your custom modules:
http://kb.x-cart.com/

What you are to do is create a custom module that decorates the \XLite\View\Form\Product\Search\Customer\SimpleFor m class and tweaks the getDefaultParams() method as Igor advised:
https://forum.x-cart.com/showpost.php?p=395690&postcount=4



I saw his post above, but thank you for linking it here.
So, I just "decorate" it? Awesome. Whatever that means.

Thanks for your help Alex

qualiteam 04-27-2016 05:14 AM

Re: Product Search
 
Did you check the http://kb.x-cart.com/ link that I posted too?
This documentation for developers explains a lot of things including what "decorate" means.
For instance, check this article:
http://kb.x-cart.com/display/XDD/Adding+CSS+and+JS+files+for+Mobile+Skin


All times are GMT -8. The time now is 09:34 AM.

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