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 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料