Jump to content

[SOLVED] {$product->id_supplier == 1} doesnt work in product_list


wzr1one

Recommended Posts

Hello, 

i want to make an exception in product-list.tpl:

 

When id of supplier is making something else is making something else, in product.tpl it works fine with {if $product->id_supplier == 1} but in product-list.tpl give me an error with - 

 

Notice: Trying to get property of non-object in .../tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 98

 

What should i change to use this? 

 

EDIT

 

Same thing in blocknewproducts.tpl and probably in viewedproducts

 

Regards!

 

Its prestashop 1.6.1.9 

Edited by wzr1one (see edit history)
Link to comment
Share on other sites

ive got reply in polish version of forum:

 

{$product.id_supplier}

{$newproduct.id_supplier}

{$viewedProduct->id_supplier}

 

but the lastone doesnt work

 

it gives : Undefined property: stdClass::$id_supplier in error

 

Last one should be {$viewedProduct.id_supplier}

 

Edit: it should be {$viewedProduct->id_supplier} indeed, but some changes are required on the module's php file. Refer to my post below.

Edited by w3bsolutions (see edit history)
Link to comment
Share on other sites

when i changed it to your solutuion it gave me fatal error:

 

Fatal error: Uncaught Error: Cannot use object of type stdClass as array in /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code:61 Stack trace: #0 /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/tools/smarty/sysplugins/smarty_internal_templatebase.php(188): content_58443ed148e8b0_93887942(Object(Smarty_Custom_Template)) #1 /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/classes/SmartyCustom.php(317): Smarty_Internal_TemplateBase->fetch(Object(Smarty_Custom_Template), NULL, NULL, NULL, false, true, false) #2 /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/classes/module/Module.php(2309): Smarty_Custom_Template->fetch() #3 /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/modules/blockviewed/blockviewed.php(136): ModuleCore->display('/home/myaccount/d...', 'blockviewed.tpl') #4 /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/modules/blockviewed/blockviewed.php(143): BlockViewed- in /home/myaccount/domains/myaccount.mysite.pl/public_html/mycatalog/tools/smarty/sysplugins/smarty_internal_templatebase.php(157) : eval()'d code on line 61

Link to comment
Share on other sites

Oops, sorry, my bad. It should be {$viewedProduct->id_supplier} indeed. But you have to make some changes in /modules/blockviewed/blockviewed.php first:

 

Replace line 83:

SELECT MAX(image_shop.id_image) id_image, p.id_product, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite

with this: 

SELECT MAX(image_shop.id_image) id_image, p.id_product, p.id_supplier, il.legend, product_shop.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite

Around line 116, after: 

$obj->category_rewrite = $productsImagesArray[$productViewed]['category_rewrite'];

add this:

$obj->id_supplier = $productsImagesArray[$productViewed]['id_supplier'];

Then in the tpl file you can use {$viewedProduct->id_supplier}

Let us know if this works.

 

Remember to apply these changes with an override if you don't want to lose them with updates. 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...