Prestashop function: Get product information
P粉298305266
P粉298305266 2024-03-29 17:09:04
0
1
320

It's just here that I got stuck on a problem that I don't quite understand!

I tried restoring all the products that were running fine:

        $id_lang = (int)Context::getContext()->language->id;
        $start = 0;
        $limit = 100;
        $order_by = 'id_product';
        $order_way = 'DESC';
        $id_category = false;
        $only_active = true;
        $context = null;
        $all_products = Product::getProducts($id_lang, $start, $limit, $order_by, $order_way, $id_category, $only_active, $context);

Except I only need to display products with a predefined ID.

P粉298305266
P粉298305266

reply all(1)
P粉410239819

Use the constructor to get a specific Product instance via id_product.

/** @var int Specific Product ID */
$id_product = 1337;

/** @var Product Specific Product instance */
$specific_product = new Product($id_product);

if(false !== $specific_product) {
  // Product found in database, so can use instance
} else {
  // Product does not exist
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!