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条)

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?