JSilva Posted October 24, 2019 Share Posted October 24, 2019 Hi, how can i get the id_product_1 knowing the id_product_2 in my .tpl? And another question, how can i redirect custom product to another product? Regards Link to comment Share on other sites More sharing options...
NemoPS Posted October 25, 2019 Share Posted October 25, 2019 how are those products related? Link to comment Share on other sites More sharing options...
JSilva Posted October 28, 2019 Author Share Posted October 28, 2019 I send an attach. first of all, how i get the id_product_1 knowing id_product_2. For example, the product which id is 810 (id_product_2)m how can i get the id 812 (id_product_1)? And the second question, if in the top search i write for example 'product1' and the result appear the 'product1' product, but when i enter that product, dont open the 'product1' page but link to anothe product, like 'productXX'? Regards Link to comment Share on other sites More sharing options...
JSilva Posted October 28, 2019 Author Share Posted October 28, 2019 Now, with the attach Link to comment Share on other sites More sharing options...
NemoPS Posted October 28, 2019 Share Posted October 28, 2019 Hmm ok, so you have the database data. You need to get that in productController.php, ideally make your own method, then call it in initContent. This way you can assign it to the template, and then use it. As for the search, not sure, it might be a bug. Link to comment Share on other sites More sharing options...
JSilva Posted October 30, 2019 Author Share Posted October 30, 2019 NemoPS, can you be more specific please? Link to comment Share on other sites More sharing options...
JSilva Posted November 6, 2019 Author Share Posted November 6, 2019 (edited) Hi, i've solved but know i need change it, and that change is not function... This is in Product.php public static function teste($id_product){ // $sql = 'SELECT count(*) AS count FROM `ps_product` WHERE `id_product`='.(int)$id_product; $sql = 'SELECT id_product_1 AS prod FROM `ps_accessory` WHERE `id_product_2`='.(int)$id_product; $result = Db::getInstance()->getRow($sql); // return $result['count']; return $result['prod']; } and in catalog/product.tpl {Product::teste(Tools::getvalue('id_product'))} {$link->getProductLink({Product::teste(Tools::getvalue('id_product'))}, $smarty.get.id_product.link_rewrite)|escape:'htmlall':'UTF-8'} thid function very well. But when i want to do the some in catalog/_partials/miniatures/product.tpl {Product::teste(Tools::getvalue('id_product'))} this return empty. Also echo test words in method, and those word appear on screen, and the variable $id_product is always empty. anyone know why? Regards Edited November 8, 2019 by JSilva (see edit history) 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