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

BrandonLR 08-01-2016 09:25 AM

Default Search Module / Tutorial
 
I originally asked this question a few months ago.
Changing the default search parameter from 'any words' to 'all words'

I see now that this has been added as a module tutorial/walk-through in the developer section.

I followed it along to the best of my understanding but when I redeployed the store, it got hung op on Step 6 of 13.

I am wondering if I did something wrong and if someone can help me out here.

I created a simple module as outlined here:
http://devs.x-cart.com/en/getting_started/step_1_-_creating_simplest_module.html

After creating the module I uploaded it and redeployed the store. The empty module is showing up just fine.

Now, this next series of steps is confusing me:
http://devs.x-cart.com/en/customization_examples/resetting_the_search_parameter_from_any_word_to_al l_words.html

Step 2. Says "In this module, add a new class:"

Do I add this at the bottom of the simple module file (Main.php), just after this chunk of code...
Code:

public static function getDescription()
    {
        return 'Resets the search parameter from any word to all words';
    }
}

?

BrandonLR 08-01-2016 09:44 AM

Re: Default Search Module / Tutorial
 
I don't know if this was the issue but I did find an error in syntax here:
http://devs.x-cart.com/en/customization_examples/resetting_the_search_parameter_from_any_word_to_al l_words.html
Code:

namespace XLite\Module\<YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID>\View\Form\Product\Search\Customer;
class SimpleForm extends \XLite\View\Form\Product\Search\Customer\SimpleForm implements \XLite\Base\IDecorator
{
  protected function getDefaultParams()
  {
      $params = parent::getDefaultParams();
      $params[\XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING] = \XLite\Model\Repo\Product::INCLUDING_ALL;
      return $params;
  }
}


The bold & underlined forward slash between <YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID> should be a back slash, no?

BrandonLR 08-01-2016 09:47 AM

Re: Default Search Module / Tutorial
 
Also, this new Main.php file is simply in a directory I created called "DefaultSearch"
/classes/XLite/Module/Brando/DefaultSearch

If that is where the file is, should the namespace simply be
namespace XLite\Module\Brando\DefaultSearch;

or does it have to be namespace XLite\Module\Brando\DefaultSearch\View\Form\Produc t\Search\Customer;
as shown in the walk-through?

qualiteam 08-01-2016 09:00 PM

Re: Default Search Module / Tutorial
 
Quote:

Originally Posted by BrandonLR
I followed it along to the best of my understanding but when I redeployed the store, it got hung op on Step 6 of 13.

Did it happen only once?

Quote:

Originally Posted by BrandonLR
Step 2. Says "In this module, add a new class:"
Do I add this at the bottom of the simple module file (Main.php), just after this chunk of code...?


No, you should create the following new file and enter its contents as per the documentation:
classes/XLite/Module/YOUR-DEVELOPER-ID/YOUR-MODULE-ID/View/Form/Product/Search/Customer/SimpleForm.php

Quote:

Originally Posted by BrandonLR
The bold & underlined forward slash between <YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID> should be a back slash, no?


Yes, it should be a back slash. Thank you for finding this!

Quote:

Originally Posted by BrandonLR
Also, this new Main.php file is simply in a directory I created called "DefaultSearch"
/classes/XLite/Module/Brando/DefaultSearch

If that is where the file is, should the namespace simply be
namespace XLite\Module\Brando\DefaultSearch;

or does it have to be namespace XLite\Module\Brando\DefaultSearch\View\Form\Produc t\Search\Customer;
as shown in the walk-through?



The namespace should match the path to the file.

For "classes/XLite/Module/Brando/DefaultSearch/Main.php" the namespace should be "XLite\Module\Brando\DefaultSearch", and the class name should be "Main".

For "classes/XLite/Module/Brando/DefaultSearch/View/Form/Product/Search/Customer/SimpleForm.php" the namespace should be "XLite\Module\Brando\DefaultSearch\View\Form\Produ ct\Search\Customer", and the class name should be "SimpleForm".

BrandonLR 08-01-2016 09:07 PM

Re: Default Search Module / Tutorial
 
Quote:

Originally Posted by qualiteam
No, you should create the following new file and enter its contents as per the documentation:
classes/XLite/Module/YOUR-DEVELOPER-ID/YOUR-MODULE-ID/View/Form/Product/Search/Customer/SimpleForm.php



The documentation only says
Code:

namespace XLite\Module\<YOUR-DEVELOPER-ID>/<YOUR-MODULE-ID>\View\Form\Product\Search\Customer;
class SimpleForm extends \XLite\View\Form\Product\Search\Customer\SimpleForm implements \XLite\Base\IDecorator
{
  protected function getDefaultParams()
  {
      $params = parent::getDefaultParams();
      $params[\XLite\View\ItemsList\Product\Customer\Search::PARAM_INCLUDING] = \XLite\Model\Repo\Product::INCLUDING_ALL;
      return $params;
  }
}


Could you please update the documentation with the needed corrections?
http://devs.x-cart.com/en/customization_examples/resetting_the_search_parameter_from_any_word_to_al l_words.html

qualiteam 08-02-2016 07:59 PM

Re: Default Search Module / Tutorial
 
Quote:

Originally Posted by BrandonLR
Could you please update the documentation with the needed corrections?


I've asked the person who wrote the article to tweak it.
Thank you!

BrandonLR 08-03-2016 07:34 AM

Re: Default Search Module / Tutorial
 
Quote:

Originally Posted by qualiteam
I've asked the person who wrote the article to tweak it.
Thank you!


Thank you. I also figured it out and got it to work. I appreciate your help and clarity.

I am curious though- why so many empty directories?


All times are GMT -8. The time now is 10:53 AM.

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