访问 Magento 自定义属性
我有两个自定义属性,一种称为“amz_prod_description”,一种称为“upc”。
我应该能够访问它们 $product->getUpc() 和$product->getAmzProdDescription() 其中 $product.在同一个交换机中,我同时使用这两个。 'upc' 属性 var 工作正常,另一个根本不起作用,这真的让我很烦恼,因为它们都使用 Magento 要求的方法并且在同一个 PHP 函数中。所以它们都处于相同的上下文中,等等。
帮助我!? :\
这是我的实际代码,它的价值>
case "{amazon_description}":
$description = $product->getAmzProdDescription();
// I have tested, $description is not being set. I have changed the bottom return to just $description and it returns nothing.
if(strlen($description) > 1499) {
$amz_description = substr($description,0,1500) . "...";
} else {
$amz_description = $description;
}
return $amz_description;
break;
case "{upc}":
$upc = $product->getUpc();
return $upc;
break;
I have two custom attributes, one called 'amz_prod_description' and one called 'upc'.
I should be able to access them both $product->getUpc() and $product->getAmzProdDescription() where $product. In the same switch, I am using both of these. The 'upc' attribute var works fine, the other doesn't work at all which is really bugging the you-know-what out of me as they're both using the methodology that Magento calls for and in the same PHP function. So they're both in the same context, etc.
Help me!? :\
Here's my actual code for what it's worth >
case "{amazon_description}":
$description = $product->getAmzProdDescription();
// I have tested, $description is not being set. I have changed the bottom return to just $description and it returns nothing.
if(strlen($description) > 1499) {
$amz_description = substr($description,0,1500) . "...";
} else {
$amz_description = $description;
}
return $amz_description;
break;
case "{upc}":
$upc = $product->getUpc();
return $upc;
break;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Magento 管理员的属性管理中有一个标志,称为“在前端的产品视图页面上可见”。确保这两个属性都设置为“Yes”,否则该属性将不会构建到 getData 数组中。这假设您的代码在前端运行,尽管您尚未指定。
还要确保重建索引并刷新缓存和缓存。缓存存储。
There's a flag in the attribute management in the Magento admin called "Visible on Product View Page on Front-end". Make sure that's set to "Yes" for both attributes, otherwise the attribute won't be built into the getData array. This assumes that your code is running in the frontend, although you haven't specified that.
Also make sure you rebuild indexes and flush the cache & cache storage.