Magento:在类别列表页面上显示等级价格 [英] Magento: Display tier prices at category listing page

查看:66
本文介绍了Magento:在类别列表页面上显示等级价格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在类别列表页面(catalog/product/list.phtml)上显示所有等级的价格,但仅获得单个产品的基本价格.

I'm trying to display all tier prices on category listing page (catalog/product/list.phtml) but only getting the basic price for a single product.

print_r($_product->getTierPrice());

返回:

Array
(
    [0] => Array
        (
            [price] => 0.5000
            [website_price] => 0.5000
            [price_qty] => 1
            [cust_group] => 32000
        )

)

每个产品的

.在产品信息页面上,它可以解决问题.请告知.

for each product. On the product info page it works w/o problems. Please advise.

ver. 1.5.0.1

ver. 1.5.0.1

更新:

这是受以下答案启发的问题的解决方案:

Here is the solution for the problem inspired with the answer below:

$resource = Mage::getSingleton('core/resource');
$query = 'SELECT * FROM ' . $resource->getTableName('catalog/product') . '_tier_price';
$_tier_prices = $resource->getConnection('core_read')->fetchAll($query);
var_dump($_tier_prices);

推荐答案

Magento中的所有对象都可能在不同的页面上以不同的方式创建,并且其中包含不同的数据.乍一看似乎不合常理.碰巧,将数据加载到项目"页面上的$ _product对象中的db查询中几乎包含了所有数据.但是出于优化目的,类别页面上使用的$ _product仅包含一些数据-如果我没记错的话,它甚至是从不同的数据库表中提取的.例如,类别页面上的查询与catalogindex *表联接,以获取通常从常规eav表中检索到的某些数据.

All objects in Magento can potentially be created differently on different pages, and have different data in them. It might seem unintuitive at first. It happens that the db query that loads the data into the $_product object on the Item page has pretty much "all" the data in it. But for optimization purposes the $_product used on the category page only has some of the data - and if I remember correctly, it even pulls from different db tables. For example, the the query on the category page joins against the catalogindex* tables for some of the data that would normally be retrieved from the regular eav table.

我没有任何要提供的详细信息,但是您可以直接根据具有所有层级定价的catalog_product_entity_tier_price表进行查询.至少那是我的magento版本中的表格名称,不是1.5.副作用是由于额外的查询/查询,类别页面的加载时间会更长.

I don't have any specifics to give to you but you can look at querying directly against the catalog_product_entity_tier_price table, which has all the tier pricing. At least that is the table name in my version of magento, which isn't 1.5. Side effect would be that the category page will take longer to load due to the extra query/queries.

这篇关于Magento:在类别列表页面上显示等级价格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆