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)
-   -   is it possible to override a module's yaml info (https://forum.x-cart.com/showthread.php?t=72068)

cvaughan02 05-11-2015 09:12 AM

is it possible to override a module's yaml info
 
I have a client that wants to modify the "brands" module to say "designer". I've accomplished this almost everywhere, except that the menu item and the url (?target=brands) are set in the yaml file.

obviously i'm trying to accomplish this while maintaining upgradability.:roll:

any direction would be appraciated.

totaltec 05-11-2015 09:42 AM

Re: is it possible to override a module's yaml info
 
Can you post a copy of the yaml? Are you talking about the admin side of customer side? I am sure that there is a way to do this in your own module. yaml files usually just insert data into the database, that is later referenced by a php file. We just have to find the file that references it, and decorate that class in our own module.

cvaughan02 05-11-2015 10:01 AM

Re: is it possible to override a module's yaml info
 
Quote:

Originally Posted by totaltec
Can you post a copy of the yaml? Are you talking about the admin side of customer side? I am sure that there is a way to do this in your own module. yaml files usually just insert data into the database, that is later referenced by a php file. We just have to find the file that references it, and decorate that class in our own module.


Here's the part of the yaml I was thinking I'd override:


XLite\Module\CDev\SimpleCMS\Model\Menu:
- link: '?target=brands'
type: P
position: 150
translations:
- code: en
name: 'Brands'
- code: ru
name: 'Бренды'


as you can see, it places the literal string there, so I wasn't sure how to modify that. Although, I'm thinking maybe I could use my own yaml and insert my own menu item and then remove theirs from the menu ( I think that's an option). however, that'd still leave '?target=brands' as a valid url that could get crawled, which might ding us for seo purposes.

Ideally, I want to accomplish this without a bunch of manual steps in the backend, so it will be easily migratable to other stores.

thanks for the reply.

totaltec 05-11-2015 10:25 AM

Re: is it possible to override a module's yaml info
 
Okay yes as you expect, this is just a menu item. The best way to fix this is just a simple edit of the menu. Then you can edit the language variable.

If it was your own module then this would be something to change, but since it a purchased one just make the change manually in the admin.

cvaughan02 05-11-2015 12:07 PM

Re: is it possible to override a module's yaml info
 
ok, so that didn't work like I was thinking :(

I got the menu saying what I want, but how do I make ?target=designers point to the brands page (where ?target=brands currently goes). Basically, how do I setup in a module what target goes where.

totaltec 05-11-2015 04:43 PM

Re: is it possible to override a module's yaml info
 
I'd search the module itself for the word brand and the word target. Then you will hopefully find the php file and method you need to decorate. I have several tutorials where I demonstrate these techniques.

totaltec 05-11-2015 04:45 PM

Re: is it possible to override a module's yaml info
 
But don't edit the module files directly, decorate them with your own custom module. Watch my tutorials and read/watch Tony's. Then if you still need help, we will be here.

cvaughan02 05-12-2015 05:26 AM

Re: is it possible to override a module's yaml info
 
Quote:

Originally Posted by totaltec
I'd search the module itself for the word brand and the word target. Then you will hopefully find the php file and method you need to decorate. I have several tutorials where I demonstrate these techniques.


that's how I found the yaml file. it was the only place. I'm assuming this is an xcart thing more than a module thing, or its possible they're loading the info from a variable where it wouldn't show up in a content search. I'm still looking though.

I guess, my question is, in the url when we get ?target=[somevalue], where in xcart controls what that does? because that url structure is not unique to this module. My Account goes to '?target=order_list'. So, where are targets defined, I guess?

totaltec 05-12-2015 08:30 AM

Re: is it possible to override a module's yaml info
 
I was able to get my hands on a copy of the Brands module.

In Module/QSL/ShopByBrand/View/Brand.php I see this method:

Code:

/**
 * Brand page view
 *
 * @ListChild (list="admin.center", zone="admin")
 */
class Brand extends \XLite\View\AView
{
    /**
    * Return list of allowed targets
    *
    * @return array
    */
    public static function getAllowedTargets()
    {
        return array_merge(parent::getAllowedTargets(), array('brand'));
    }


this is the method I would override in my decorator. It may be other places, this is just the first I found.

cvaughan02 05-12-2015 10:13 AM

Re: is it possible to override a module's yaml info
 
Quote:

Originally Posted by totaltec
I was able to get my hands on a copy of the Brands module.

In Module/QSL/ShopByBrand/View/Brand.php I see this method:

Code:

/**
 * Brand page view
 *
 * @ListChild (list="admin.center", zone="admin")
 */
class Brand extends \XLite\View\AView
{
    /**
    * Return list of allowed targets
    *
    * @return array
    */
    public static function getAllowedTargets()
    {
        return array_merge(parent::getAllowedTargets(), array('brand'));
    }


this is the method I would override in my decorator. It may be other places, this is just the first I found.



Ahhhh, thank you! I will try that shortly. I'm pretty sure that's what i need though. I saw this function early on in my search, but I hadn't figured out I was looking for targets yet.. its much more relevant now :D


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

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