如何在自定义.phtml文件中调用产品自定义属性
-
12-12-2019 - |
题
我想在我自己的.phtml文件中调用一个产品自定义属性,但是有一些问题。任何帮助都非常感谢。
我在我的模板/目录/ product / appiew.phtml文件中有以下代码:
<?php echo $this->getLayout()->createBlock('core/template')->setTemplate('customstuff/deliveries_returns.phtml')->toHtml(); ?>
.
在模板/ customstuff / transperies_returns.phtml中调用我自己的自定义.phtml文件_returns.phtml
在那个.phtml文件中我有这个代码:
Delivery Times:</strong> <?php echo $_product->getshipping_times() ?></p>Delivery Costs: <?php echo $_product->getdelivery_costs() ?></p>
.
我已经设置了属性代码specion_times和treation_costs 的自定义属性
在我的网站前端,我收到以下错误消息:生产时间: 致命错误:调用在/home/cuffandc/public_html/app/design/frontend/mytheme/default/template/customstuff/deliveries_returns.phtml上的非对象上的成员函数getshipping_times()上
任何帮助非常感谢!
解决方案
在tervanties_return.phtml中找不到对象的产品对象。
可以尝试
<?php
echo $this->getLayout()->createBlock('catalog/product_view')->setTemplate('customstuff/deliveries_returns.phtml')->toHtml();
?>
.
并在递送中添加此代码_returns.phtml
<?php $_product = $this->getProduct(); ?>
Delivery Times:</strong> <?php echo $_product->getshipping_times() ?></p>Delivery Costs: <?php echo $_product->getdelivery_costs() ?></p>
.