gpt4 book ai didi

magento - 非对象上的 getID()

转载 作者:行者123 更新时间:2023-12-04 17:36:35 24 4
gpt4 key购买 nike

当我使用 magentoshop 访问页面时;我收到此错误消息:

在第 85 行的/xxxxx/app/code/core/Mage/Catalog/Model/Product/Type/Configurable/Price.php 中的非对象上调用成员函数 getId()

我走向那条线,它是名为 getTotalConfigurableItemsPrice 的函数的一部分。
它在一个 foreach 中:

它说:

foreach ($attributes as $attribute) {
$attributeId = $attribute->getProductAttribute()->getId();

属性的东西是问题所在。
我在 $attribute->getProductAttribute() 上尝试了 var_dump()
并收到 NULL
一个 var_dump on($attribute) 显示即
["_data":protected]=>
array(5) {
["product_super_attribute_id"]=>
string(4) "3845"
["product_id"]=>
string(8) "10001563"
["attribute_id"]=>
string(3) "135"
["position"]=>
string(1) "0"
["product_attribute"]=>
NULL
}

属性有什么问题,我该如何解决?
如果我说:
$attributeId = 1234;

代替
$attributeId = $attribute->getProductAttribute()->getId();

错误消失了,但我需要真正的值(value)..

最佳答案

我遇到了同样的问题并找到了解决方案。

问题描述:

该问题影响属性集为“默认”和可配置属性“颜色”的可配置产品。基于“默认”创建了一个新的属性集,并从该属性集中删除了属性颜色。后来通过一些 3rd 方扩展,一些可配置产品的属性集被更改为新的。这就是问题的根源。

解决方案:

在问题产品的属性集中添加属性“颜色”。

联系方式:

给定产品的可配置属性存储在表 catalog_product_super_attribute 中。 .使用产品的 id,您可以找出这些属性。

mysql> select * from catalog_product_super_attribute where product_id=1826;
+----------------------------+------------+--------------+----------+
| product_super_attribute_id | product_id | attribute_id | position |
+----------------------------+------------+--------------+----------+
| 1826 | 1826 | 92 | 0 |
| 2683 | 1826 | 209 | 0 |
+----------------------------+------------+--------------+----------+
mysql> select attribute_id,attribute_code from eav_attribute where (attribute_id=92 or attribute_id=208);
+--------------+----------------+
| attribute_id | attribute_code |
+--------------+----------------+
| 92 | color |
| 208 | color_mutsy |
+--------------+----------------+

您所要做的就是转到您的管理员目录 - 属性 - 管理属性集并将属性添加到有问题的产品的属性集并重新编制索引。

关于magento - 非对象上的 getID(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16942701/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com