Jump to content

Product Accessories


JSilva

Recommended Posts

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

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

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 by JSilva (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...