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)
-   -   Related Products - List View? (https://forum.x-cart.com/showthread.php?t=69013)

Mark N 04-11-2014 06:46 AM

Related Products - List View?
 
Using the example given by Tony on the webinar yesterday (thanks for that Tony!), trying to change the default view for related products from grid to list view. Here's what I have done:

Created in my own theme XLite\Module\Alinc\AlincTheme\View\ItemsList\Upsel lingProducts\UpsellingProducts.php with the following code:

PHP Code:

<?php

namespace XLite\Module\Alinc\AlincTheme\View\ItemsList\UpsellingProducts;

/**
 * Abstract widget
 */

abstract class UpsellingProducts extends XLite\Module\XC\Upselling\View\ItemsList\UpsellingProducts implements \XLite\Base\IDecorator
{
    protected function 
defineWidgetParams()
    {
        
parent::defineWidgetParams();

        
$this->widgetParams[static::PARAM_DISPLAY_MODE] = new \XLite\Model\WidgetParam\Set('Display mode', static::DISPLAY_MODE_TABLEtrue, array());
    }
}


That said, it doesn't seem to be working. Am I going about this all wrong?

-Mark

totaltec 04-11-2014 08:00 AM

Re: Related Products - List View?
 
Mark, I am going to try and do the same thing, see what happens.

Mark N 04-11-2014 08:04 AM

Re: Related Products - List View?
 
Thanks Mike - my guess is I have the file in the wrong place and/or wrong file name and/or the class I am extending wrong. I am only now beginning to understand how the MVC architecture works...

totaltec 04-11-2014 08:06 AM

Re: Related Products - List View?
 
Well in this case it is the blind helping the blind, I am getting there, but my understanding is still newb level with XC5. The transition to OOP, MVC, and Doctrine2 logic all at once is splitting my head.

Mark N 04-11-2014 08:23 AM

Re: Related Products - List View?
 
I think you're very much in the majority there. The constant need to rebuild the cache is also a real development-killer - having to wait 30-60 seconds for a rebuild with every minor PHP tweak really limits the ability to plug at things until it starts working...

totaltec 04-12-2014 01:56 AM

Re: Related Products - List View?
 
Mark,
Edit: I posted some comments that were utterly wrong, removed. :-)

Well I have attempted to duplicate your change. At first I thought I was on to something, but it proved worthless.

I did notice one thing, your namespace is wrong I believe.

namespace XLite\Module\Alinc\AlincTheme\View\ItemsList\Upsel lingProducts;

Should just be:

namespace XLite\Module\Alinc\AlincTheme\View\ItemsList;

Still doesn't work though. I notice after rebuilding cache, that the new file we are creating is not copied into the var/run folder. Also since we are decorating the other class, I thought it would create a copy in the XC/Upselling/View/ItemsList directory, something like UpsellingProductsAbstract.php

Is it the same for you? No copied file in var\run\Module\Alinc\AlincTheme\View\ItemsList ?

It seems XC is ignoring our new file.

totaltec 04-12-2014 08:04 AM

Re: Related Products - List View?
 
Just discovered something that may be key to what we are doing. Searching for "extends XLite\Module" in the files produces 0 results.

So there is not a working example of a module extending another module.

Mark N 04-14-2014 06:17 AM

Re: Related Products - List View?
 
1 Attachment(s)
Mike,

Ok, so I can say that in my tests at least the module is being copied properly, but not to where you are looking - it is in var/run/classes/Xline/Module/Alinc/AlincTheme/View/ItemsList/UpsellingProducts/UpsellingProducts.php

that said, it's not running it, at least as far as I can tell. The copy as it appears in the var/run shows up as:

PHP Code:

<?php

namespace XLite\Module\Alinc\AlincTheme\View\ItemsList\UpsellingProducts;

/**
 * Abstract widget
 */
abstract class UpsellingProducts extends \XLite\Module\XC\Upselling\View\ItemsList\UpsellingProductsAbstract implements \XLite\Base\IDecorator
{
    protected function 
defineWidgetParams()
    {
        
parent::defineWidgetParams();

        
$this->widgetParams[static::PARAM_DISPLAY_MODE] = new \XLite\Model\WidgetParam\Set('Display mode', static::DISPLAY_MODE_TABLEtrue, array());
    }
}


And it is in fact turning it into UpsellingProductsAbstract when it compiles.

Not sure why your code isn't making it at least that far,maybe an error in your Main.php? Attaching mine here.

And like yourself I couldn't find anyone who has made a module that extends another module, although obviously there will be cases where people want to do exactly that.

Mark N 04-14-2014 06:33 AM

Re: Related Products - List View?
 
Ok, onto something here. Looks like people have extended other modules, for example the Social module (and others) extend SimpleCMS, the bit of code you need is:


PHP Code:

namespace XLite\Module\CDev\GoSocial\View;

/**
 * Main page page
 *
 * @LC_Dependencies ("CDev\SimpleCMS")
 */
abstract class Page extends \XLite\Module\CDev\SimpleCMS\View\CustomerPage implements \XLite\Base\IDecorator



The Key is the @LC_Dependencies bit.

So in our case we will be dependent on XC\Upselling.

Trying this out...

totaltec 04-14-2014 06:43 AM

Re: Related Products - List View?
 
Very cool! Thanks Mark, this help me tremendously in some of my other projects. Waiting to hear back from you on how your tests go. I may be able to attempt this again myself later today...


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

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