Magento 帮助 ->难以过滤新产品
我有点进退两难。以下代码正确显示分配的产品,同时忽略最低定价。 “低至”选项。
<?php
$cat_id = 123; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$_products = $category->
getProductCollection()->
addCategoryFilter($category)->
addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->
addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')->
addAttributeToSelect('*');
if (($this->getProductCollection()) && $_products->getSize()): ?>
对最后一行进行小幅调整,正确显示“低至”价格,但最终会在该类别中添加未分配的产品。
if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
我缺少什么?谢谢
I'm having a little dilemma. The following code correctly displays the assigned products while ignoring the minimal pricing. The "as low as" option.
<?php
$cat_id = 123; // category id
$category = Mage::getModel('catalog/category')->load($cat_id);
$todayDate = Mage::app()->getLocale()->date()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT);
$_products = $category->
getProductCollection()->
addCategoryFilter($category)->
addAttributeToFilter('news_from_date', array('date' => true, 'to' => $todayDate))->
addAttributeToFilter('news_to_date', array('or'=> array(
0 => array('date' => true, 'from' => $todayDate),
1 => array('is' => new Zend_Db_Expr('null')))
), 'left')->
addAttributeToSelect('*');
if (($this->getProductCollection()) && $_products->getSize()): ?>
Minor adjustment of last line, correctly shows the "as low as" price, but ends up adding un-assigned products within said category.
if (($_products = $this->getProductCollection()) && $_products->getSize()): ?>
What am I missing? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是适合任何感兴趣的人的解决方案。
我有兴趣在同一文件中使用另一个类别 ID 重复此过程。清理初始产品集合的最佳方法是什么?
Here's the solution that worked for anyone interested.
I am interested repeating this procedure within same file with another category id. What's the best way clearing the initial product collection.