douzhuo2722 2014-12-25 16:20
浏览 29
已采纳

Prestashop从其id获取产品属性

In Prestashop I want to get product's all attribute from its product id. Lets say I have a product with id as 3. Now from product id 3 I want to get all of its attribute like name, price, stock, category, product link.. etc.

So far I have tried

$product_id = $result['id_product'];
$id_product = (int)$product_id;
$product = new Product(Tools::getValue($id_product));
var_dump($product);

But its giving me an array with all attributes in blank. The array can be seen here

So can someone tell me how to get its all attribute from id? Any help and suggestions will be really appreciable. Thanks

  • 写回答

2条回答 默认 最新

  • dongyu5104 2014-12-25 18:09
    关注

    Well, one obvious mistake is

    Tools::getValue($id_product)
    

    Which is basically

    $_GET[$id_product]
    

    So in your case that would probably evaluate to

    $product = new Product($_GET['3']);
    

    So remove Tools::getValue and try again:

    $product_id = $result['id_product'];
    $id_product = (int)$product_id;
    $product = new Product($id_product);
    var_dump($product);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?