preoteasa Posted May 19, 2019 Share Posted May 19, 2019 Is it possible to modify a smarty product variable (for example $product.show_price) from a display hook associated to the product page (for example displayProductAdditionalInfo) in a module? Link to comment Share on other sites More sharing options...
Rolige Posted May 21, 2019 Share Posted May 21, 2019 Hello: Yes you can. Just assign again the variable you want and it will be overrided. Remember that $product.show_price is not a variable, you must override the complet $product variable. Regards Link to comment Share on other sites More sharing options...
preoteasa Posted May 30, 2019 Author Share Posted May 30, 2019 Hello, Thank you for your message. I got one step further, but I still don't know how to update show_price. For example if I do: $product = $params['smarty']->getTemplateVars('product'); print_r('ProductAdditionalInfo - show_price: ' . $product['show_price']); inside the hook displayProductAdditionalInfo, I get the expected value "ProductAdditionalInfo - show_price: 1". However if I try to update show_price within $product: $product->show_price = 0; I get the error: "Trying to set the index show_price of the LazyArray PrestaShop\PrestaShop\Adapter\Presenter\Product\ProductLazyArray already defined by a method is not allowed" I tried to find how to update fields of LazyArray but without any success. If I try to do the similarly in the hook FilterProductContent $product = $params['object']; print_r('FilterProductContent - show_price: ' . $product['show_price']); $product['show_price'] = 0; I get the same error. I general I think that the hook FilterProductContent is more appropriate for changing show_price, but I am stuck with this simple problem of updating this field. 1 Link to comment Share on other sites More sharing options...
lmeyer Posted January 21, 2021 Share Posted January 21, 2021 I have the same problem. https://github.com/PrestaShop/PrestaShop/issues/22938 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now