搜索

首页  >  问答  >  正文

Prestashop功能:获取产品信息

只是在这里我陷入了一个我不太理解的问题!

我尝试恢复所有运行良好的产品:

        $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);

除了我只需要显示具有预定义 ID 的产品。

P粉298305266P粉298305266318 天前424

全部回复(1)我来回复

  • P粉410239819

    P粉4102398192024-03-30 15:20:32

    使用构造函数通过id_product获取特定的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
    }
    

    回复
    0
  • 取消回复