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)
-   -   Move SKU on product page (https://forum.x-cart.com/showthread.php?t=72076)

Phil Richman 05-12-2015 05:44 AM

Move SKU on product page
 
I want to move the product sku out of the description tab and up to the main part of the product page under the price. I found the common.product-attributes,sku.tpl file is what displays this in the description. Everytime I try moving this into another list or moving the {getsku()} line into another tpl. It breaks the page layout. Does anyone know how to do accomplish this with out getting an error and breaking the layout? Does anyone know what would cause the error?

Phil Richman 05-12-2015 05:47 AM

Re: Move SKU on product page
 
Here is what is in the xlite.log


May 12 10:37:13 XLite [error] Trying to call undefined class method; class - "XLite\Controller\Customer\Product", function - "getSKU"
Server API: cgi-fcgi;
Request method: GET;
URI: /liberty-ascent-ii-upflush-toilet-package/;
Backtrace:
file <compiled classes repository>/classes/XLite/Base.php : 83
method XLite\Base::__call('getSKU', array(0))
method XLite\Controller\Customer\Product::getSKU()
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 168
file <compiled classes repository>/skins/PmallTheme/default/en/product/details/common_attributes/common.product-attributes.sku.tpl.php : 1
file <compiled classes repository>/skins/PmallTheme/default/en/product/details/common_attributes/common.product-attributes.sku.tpl.php : 1
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 963
file <compiled classes repository>/skins/default/en/product/details/parts/page.info.tpl.php : 2
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 963
file <compiled classes repository>/skins/default/en/product/details/page/body.tpl.php : 3
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 963
file <compiled classes repository>/skins/default/en/center_top.tpl.php : 1
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/Content.php : 73
file <compiled classes repository>/skins/default/en/center.tpl.php : 5
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/Content.php : 73
file <compiled classes repository>/skins/default/en/layout/main.center.center.tpl.php : 7
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/Content.php : 73
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 963
file <compiled classes repository>/skins/default/en/layout/main.center.tpl.php : 8
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/Content.php : 73
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 963
file <compiled classes repository>/skins/default/en/main.tpl.php : 5
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 297
file <compiled classes repository>/classes/XLite/View/Content.php : 73
file <compiled classes repository>/classes/XLite/View/AViewAbstract.php : 319
file <compiled classes repository>/classes/XLite/View/ControllerAbstract.php : 291
file <compiled classes repository>/classes/XLite/View/ControllerAbstract.php : 320
file <compiled classes repository>/classes/XLite/View/ControllerAbstract.php : 136
file <compiled classes repository>/classes/XLite/Controller/AControllerAbstract.php : 558
file <compiled classes repository>/classes/XLite.php : 503
file <X-Cart root>/cart.php : 36

totaltec 05-13-2015 08:43 PM

Re: Move SKU on product page
 
Phil,

I don't the energy to research this or explain properly. But here is the bottom line:

This call to getSku() references a method that is available in the class that draws/renders this other template. In the template that you have placed this call, the PHP file that defines the class, does not have this method implemented.

You need to look into the class that renders the template that you are working in, decorate it, and include this method getSku(). Perhaps in the template you are in, you simply need to use something like {$product->getSku()} - just an example.

You just need to gain an understanding of what is assigned, and what variables and methods you have available to you, and realize that this is determined by what class (php file) this template is rendered by, and what that class may possibly extend.

qualiteam 05-19-2015 09:31 AM

Re: Move SKU on product page
 
Hi,

In X-Cart 5 a "widget" is a combination of a template file and a PHP class that provides methods to that template file.
It's the PHP class that provides methods like getSKU() to template files.

Even when you don't specify a PHP class for a template (for example, when you add a template into a list with the @ListChild tag), there is a PHP class inherited from the parent template file. In case of @ListChild the parent template is the template where the list is displayed.

When you move a template from one list to another, it changes the parent template. In your case the new parent template has a different PHP class associated with it, and, in that PHP class, there is no getSKU() method.

What you can do:

1. In your custom module create a new View class and declare getSKU() method there. Add the @ListChild tag to that class (instead of adding it to the template) and point getDefaultTemplate() to the template file that you need.

2. Find another list that has getSKU() method available and add your template there.

3. Find what PHP class is used when you call getSKU() method in the new list, decorate that class in your module and add getSKU() method there. In your case the class is /XLite/View/Content (see the error message). It is one of the top View classes, so I would prefer the first method (creating a new View class) instead of decorating this one.


All times are GMT -8. The time now is 05:22 PM.

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