我在Magento中使用以下函数有问题:
<?php echo $this->getAddToCartUrl($_product) ?>
<?php echo $this->getPriceHtml($_product, true) ?>
我在一个自定义phtml文件中使用它们,从cms页面调用,代码为:
<?php print $this->getLayout()
->createBlock("core/template")
->setTemplate("page/cms/aide/affichage-demo.phtml")
->toHtml(); ?>
$this->getAddToCartUrl($_product)
或$this->getPriceHtml($_product, true)
不返回任何值。$_product
不是问题,因为其他函数很好地返回其他属性。
下面运行正常
<?php echo $_product->getProductUrl() ?>
但这不是:
<?php echo $_product->getAddToCartUrl() ?>
任何想法如何得到getAddToCartUrl
和getPriceHtml
的工作?
购物车地址
Mage::helper('checkout/cart')->getAddUrl($product);
必须在这里将产品对象变量名更改为$_product:
Mage::helper('checkout/cart')->getAddUrl($_product);
如果可能的话,你可以创建一个不同的块:
<?php print $this->getLayout()
->createBlock("catalog/product_list")
->setTemplate("page/cms/aide/affichage-demo.phtml")
->toHtml(); ?>
此代码可从url
C:'wamp'www'magento'app'code'core'Mage'Catalog'Block'Product'View.php
.it returns $this->helper('checkout/cart')->getAddUrl($product, $additional);
getAddUrl($product, $additional)
可以从url
访问
C:'wamp'www'magento'app'code'core'Mage'Checkout'Helper'Cart.php