cmak Posted August 1, 2012 Share Posted August 1, 2012 Hi I'm writting a module and I need to catch the id of the product currently viewed. of course this is only when on a product page Link to comment Share on other sites More sharing options...
bellini13 Posted August 1, 2012 Share Posted August 1, 2012 have you hooked one of he product page hooks? if so, which one? Link to comment Share on other sites More sharing options...
cmak Posted August 2, 2012 Author Share Posted August 2, 2012 yes i did hook the extraright And i found the answer : $id_product = Tools::getValue('id_product'); Link to comment Share on other sites More sharing options...
cmak Posted August 2, 2012 Author Share Posted August 2, 2012 i needed to catch the product url and the url of the main product image. here is it with values stored in $product_link and $product_imgsrc it works but could it be more simple for links ? global $cookie, $link; $id_product = Tools::getValue('id_product'); $rewrite = (Configuration::get('PS_REWRITING_SETTINGS') == 1); $product = new Product($id_product, true, $cookie->id_lang); if ($rewrite) $product_link = $link->getproductLink($id_product, $product->link_rewrite, Category::getLinkRewrite((int)($product->id_category_default), $cookie->id_lang), $product->ean13, $cookie->id_lang); else $product_link = $link->getproductLink($id_product); $image = $product->getImages((int)($cookie->id_lang)); if (is_array($image) && sizeof($image)) { $imageObj = new Image($image[0]['id_image']); $product_imgsrc = _PS_BASE_URL_._THEME_PROD_DIR_.$imageObj->getExistingImgPath().'.jpg'; } 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