Jump to content

[ROZWIĄZANY] {$product->id_supplier == 1} nie działa w product_list


wzr1one

Recommended Posts

Witam, 

 

chciałem dodać mały warunek w product-list.tpl oraz dwóch modułach - blocknewproducts oraz blockviewed

 

wygląda on w ten sposób:

 

{$product->id_supplier == 1} 

 

cośtam

 

{else}

 

cośtam

 

{/if}

 

 

Wyrzuca mi to błąd 

 

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

 

Zastanawiam się, gdzie powinienem zmienić i co powinienem zmienić, aby to zaczęło mi działać?

 

Pozdrawiam!

 

 

Korzystam z wersji prestashop 1.6.1.9

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

Strzelałem przez analogię :), ale niestety kontroler modułu blockviewed nie pobiera id_supplier.

Trzeba zmodyfikować zapytanie do bazy:

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

 

I do obiektów dodać:

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

Link to comment
Share on other sites

Kolego, otrzymałem również na angielskiej wersji forum rozwiązanie, które zadziałało i zapomniałem tu zajrzeć :)

 

Jakby ktoś potrzebował - 

 

 

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. 

 
Edited by wzr1one (see edit history)
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...