【问题标题】:Why prestashop doesn't return product attachment's ids?为什么 prestashop 不返回产品附件的 ID?
【发布时间】:2020-10-22 16:49:30
【问题描述】:

我在产品中添加了一个 test.pdf 附件:

附件已正确保存在数据库中:

在 CategoryController 中,我正在寻找这样的附件:

$prod->getAttachments();

但如果我尝试记录结果,我会得到如下信息:

array(1) {
  [0]=>
  array(9) {
    ["id_product"]=>
    string(1) "1"
    ["id_attachment"]=>
    NULL
    ["file"]=>
    string(40) "725abb2b97837af5f29e589c56becb09b91e0c1a"
    ["file_name"]=>
    string(8) "test.pdf"
    ["file_size"]=>
    string(4) "9453"
    ["mime"]=>
    string(15) "application/pdf"
    ["id_lang"]=>
    NULL
    ["name"]=>
    NULL
    ["description"]=>
    NULL
  }
}

您可以看到file_name 是正确的,但id_attachment 字段没有填充,所以我无法像往常一样通过Link->getPageLink 建立任何链接。

为什么它不返回 id?我做错了什么?

【问题讨论】:

    标签: php prestashop attachment prestashop-1.6


    【解决方案1】:

    自己找到了答案:$prod->getAttachments();需要传递id_lang。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-20
      • 1970-01-01
      • 2014-04-25
      • 2017-07-22
      • 2012-09-15
      • 1970-01-01
      相关资源
      最近更新 更多