Magento - 无法在产品视图中显示等级定价
我根据客户群对产品设定了不同的价格。我想向客户显示这两个价格,以防它们都适用于产品列表、视图、相关和追加销售产品。
我打开模板路径提示来验证所有视图的价格是否都是从同一模板文件呈现的,如下所示:
/app/design/frontend/default/my_theme/template/catalog/product
我可以在产品列表、相关产品和追加销售产品中正确看到分层定价,但不能在产品视图中看到。
经过一段时间的调试后,我已经缩小了catalog/product/price.phtml文件中有问题的部分,如下所示:
<?php
$_coreHelper = $this->helper('core');
$_weeeHelper = $this->helper('weee');
$_taxHelper = $this->helper('tax');
$_product = $this->getProduct();
$_id = $_product->getId();
echo 'Product Id: ' . $_id;
$_weeeSeparator = '';
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
echo 'Simple Price Tax: ' . $_simplePricesTax;
$_minimalPriceValue = $_product->getMinimalPrice();
echo 'Minimal Price Value: ' . $_minimalPriceValue;
//$_minimalPriceValue = 41;
$_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
echo 'Minimal Price: ' . $_minimalPrice;
//$_minimalPrice = 41;
?>
我已经回显了从上面的模型中获取的所有价格,并且仅在产品视图页面的情况下 $_product->getMinimalPrice( )上面不会返回任何内容,但它会正确显示在列表、相关和追加销售产品上。
我想不出任何理由。 Catalog.xml 中有几行不同,但我认为它们与此没有任何关系。此外,上面的代码中有几行注释,我在其中硬编码了minimalPrice 和minimalPriceValue 变量。执行此操作后,价格也开始出现在产品视图中。所有视图(包括产品视图)的产品 ID 也正确显示,因此当时已加载产品。
我们使用的是自定义模板,我发现默认情况下我们不会遇到此问题。我正在使用 Magento 1.4.1.1
I have a different price set for products based on customer group. I want to show both price's to the customer in case both of them apply in product list, view, related and upsell products.
I turned on template path hints to verify that prices for all views are being rendered from the same template file, which is as follows:
/app/design/frontend/default/my_theme/template/catalog/product
I can see tier pricing correctly in product list, related and upsell products, but NOT for product view.
After debugging for a while I have narrowed down the problematic part of catalog/product/price.phtml file as follows:
<?php
$_coreHelper = $this->helper('core');
$_weeeHelper = $this->helper('weee');
$_taxHelper = $this->helper('tax');
$_product = $this->getProduct();
$_id = $_product->getId();
echo 'Product Id: ' . $_id;
$_weeeSeparator = '';
$_simplePricesTax = ($_taxHelper->displayPriceIncludingTax() || $_taxHelper->displayBothPrices());
echo 'Simple Price Tax: ' . $_simplePricesTax;
$_minimalPriceValue = $_product->getMinimalPrice();
echo 'Minimal Price Value: ' . $_minimalPriceValue;
//$_minimalPriceValue = 41;
$_minimalPrice = $_taxHelper->getPrice($_product, $_minimalPriceValue, $_simplePricesTax);
echo 'Minimal Price: ' . $_minimalPrice;
//$_minimalPrice = 41;
?>
I have echoed all prices fetched from models above, and only in case of product view page the $_product->getMinimalPrice() above does not return anything, while it appears correctly on list, related and upsell products.
I cannot think of any reason for this. There are a few lines different in catalog.xml but I don't think they have anything to do with this. Besides, there are a couple of commented lines in the above code, where I have hard-coded the minimalPrice and minimalPriceValue variables. After doing that the price starts appearing in product view also. The Product id for all views including product view is also appearing correctly, so the product IS loaded at that time.
We are using a custom template, and I see that in default we are not having this problem. I am using Magento 1.4.1.1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是否说过你正在尝试做的事情 100% 适合股票主题?如果是这样,那么您确实应该看看自定义主题和默认主题之间的差异。此外,您可能还想查看开发人员在 app/code/community 和 app/code/local 中对主题进行的自定义更改。可能会发生一些冲突。
但如果您找不到差异,也许我可以提供一些提示来说明为什么您可能会看到这种行为。有时,当您在类别列表页面与产品视图页面上查看时,相同的模型(和块)对象具有不同的数据。原因是后端对数据库的查询不同。我之前对分层系统做过一些工作,我记得当您查看目录页面时,定价数据实际上来自一些catalogindex_* 表,而不是catalog_product_entity_* 表。如果我没记错的话,它查询了两个表,例如catalogindex_price 和catalogindex_minimal_price。但是,当您位于产品视图页面时,定价数据来自标准的catalog_product_entity_* 和catalog_product_entity_tier_price 表。无论如何,这可能无法解决您的问题,但它可能会为您指明正确的方向。祝你好运。
Did you say that what you are trying to do works 100% with a stock theme? If so then you really should look at the differences between your custom theme and the default. Also, you might want to look at any changes the developer made in app/code/community and app/code/local that are customizations for the theme. There could be some conflict.
But if you can't find a difference maybe I can give a few hints as to why you might be seeing this behavior. Sometimes the same model (and block) objects have different data in them when you are viewing on the category list page vs the product view page. The reason is that backend queries to the database are different. I did some work with the tiering system before and I remember that when you are looking at the catalog page, the pricing data actually comes from some catalogindex_* tables rather than the catalog_product_entity_* tables. If I remember correctly, there are two tables that it queries, something like catalogindex_price and catalogindex_minimal_price. But then when you are at the product view page the pricing data comes from the standard catalog_product_entity_* and catalog_product_entity_tier_price tables. Anyway, that probably doesn't solve your problem, but it might get you pointed in the right direction. Good luck.