Jump to content

id of product currently viewed


cmak

Recommended Posts

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

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...