我需要帮助来隐藏没有图像的 Magento 产品或首先显示有图像的产品。
我在回答另一个问题时看到了这个 $this->getLoadedProductCollection()->setOrder('image'/*or small_image*/, 'desc') 首先加载所有带有图像的产品。但它对我不起作用。
我在 Magento 1.6.2 上。
提前致谢。
更新:请参阅下面我的完整 list.phtml。我想我做错了什么。谢谢。
<?php
$_productCollection=$this->getLoadedProductCollection();
$_productCollection->addAttributeToFilter('image', array('neq' => 'no_selection'));
$_helper = $this->helper('catalog/output');
$now = date("Y-m-d H:m:s");
?>
<?php if(!$_productCollection->count()): ?>
<p class="note-msg"><?php echo $this->__('There are no products matching the selection.') ?></p>
<?php else: ?>
<div class="category-products">
<?php echo $this->getToolbarHtml() ?>
<?php // List mode ?>
<?php if($this->getMode()!='grid'): ?>
<?php $_iterator = 0; ?>
<ol class="products-list" id="products-list">
<?php foreach ($_productCollection as $_product): ?>
<li class="item<?php if( ++$_iterator == sizeof($_productCollection) …Run Code Online (Sandbox Code Playgroud) magento ×1