Created
October 12, 2022 15:55
-
-
Save nympheastudio/1ae85e4821c593a16cfacc2344ba6a54 to your computer and use it in GitHub Desktop.
prestashop get image url or productName url by id product
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function getImgId(){ | |
$id = Tools::getValue('id'); | |
$action = Tools::getValue('action'); | |
if($action=='getImgId'){ | |
$id_product = $id; // set your product ID here | |
$image = Image::getCover($id_product); | |
$product = new Product($id_product, false, Context::getContext()->language->id); | |
$link = new Link; // because getImageLink is not static function | |
$imagePath = $link->getImageLink($product->link_rewrite, $image['id_image'], 'home_default'); | |
echo 'https://'.$imagePath; | |
exit; | |
} | |
} | |
public function getProductName(){ | |
$id = Tools::getValue('id'); | |
$action = Tools::getValue('action'); | |
if($action=='getProductName'){ | |
$id_product = $id; // set your product ID here | |
$product = new Product($id_product, false, Context::getContext()->language->id); | |
echo $product->name; | |
exit; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment