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)
-   -   ShopByBrand module change (https://forum.x-cart.com/showthread.php?t=71775)

skit 04-06-2015 06:36 AM

ShopByBrand module change
 
I have installed the ShopByBrand module and everything is working. But, i wanted to change the breadcrums to say "Manufactures" not "Brands."

I found the file that is controlling that to be classes>XLite>Module>QSL>ShopByBrand>View>Location >Node>Brands.php

I have created a file under my custom module XLite\Module\<mymodule>\<mymoduledesign>\View

And entered the follwoing code

Code:

namespace XLite\Module\<mymodule>\<mymoduledesign>\View;
/**
 * Home node
 */
//class Brands extends \XLite\Module\QSL\ShopByBrand\View\Location\Node implements \XLite\Base\IDecorator
class Brands extends \XLite\Module\QSL\ShopByBrand\View\Location\Node implements \XLite\Base\IDecorator
{
    /**
    * Define widget parameters
    *
    * @return void
    */
    protected function defineWidgetParams()
    {
        parent::defineWidgetParams();

        $this->widgetParams[self::PARAM_NAME]->setValue('Manufacturers');
        $this->widgetParams[self::PARAM_LINK]->setValue($this->buildURL('brands'));
    }
}


I can't get it to change on my custom module code. What should i be looking at?

Thanks in advance.

xplorer 04-09-2015 06:04 AM

Re: ShopByBrand module change
 
Hello!

An easier way to replace "Brand" with "Manufacturer" might be the following one: go to the "Store setup -> Translations" section in the back-end, search for all multilingual labels having "brand" word in them, and replace the word with "manufacturer".

Don't forget to create a backup copy of the site before editing the labels (as you may want to revert the change later).

As for the custom module - I see the following possible problems:

1. Does the namespace match the directory structure? I'm asking because your namespace ends with "View", whilst the original one is "View\Location\Node". So, it may be that you put your Brand.php file inside the View/Location/Node directory, but left the namespace pointing to the View directory.

2. There is no need in updating the "PARAM_LINK" parameter (unless you change the value), because it happens when you call "parent::defineWidgetParams();"

3. The module will trigger a fatal error if you disable Shop By Brands in your store. To fix this you should tell X-Cart 5 that you alter the class only if Shop By Brands module is enabled:
Code:

...

/**
 * Home node
 *
 * @LC_Dependencies ("QSL\ShopByBrand")
 */
class Brands extends \XLite\Module\QSL\ShopByBrand\View\Location\Node implements \XLite\Base\IDecorator
{
...


Also, without the @LC_Dependencies tag X-Cart 5 may put your code before the code added by Shop By Brands module, so that Shop By Brands overwrites yours "Manufactures" word with its "Brands" word.

Does this help?

skit 05-15-2015 06:44 AM

Re: ShopByBrand module change
 
Well, i tried to get Brands to Manufacturers in the "Store setup -> Translations" section but it didn't update the Brands in the breadcrumbs.

skit 05-15-2015 06:47 AM

Re: ShopByBrand module change
 
I appreciate your help.

here is the updated code.

Code:

namespace XLite\Module\MyModule\MyFolder\View\Location\Node;
/**
 * Home node
 *
 * @LC_Dependencies ("QSL\ShopByBrand")
 */
class Brands extends \XLite\Module\QSL\ShopByBrand\View\Location\Node implements \XLite\Base\IDecorator
{
    /**
    * Define widget parameters
    *
    * @return void
    */
    protected function defineWidgetParams()
    {
        parent::defineWidgetParams();

        $this->widgetParams[self::PARAM_NAME]->setValue('Manufacturers');
    }
}


skit 05-18-2015 05:15 AM

Re: ShopByBrand module change
 
Found the issue. The path to the class was wrong.


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

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