我可以根据产品名称过滤,我为特定产品设置的向上销售产品/将如何显示在我的表格中?我的想法是只显示以某个单词开头的产品,例如“Decor”,其余产品不会显示在表格中。这是我的代码upsell.phtml:
<?php if(count($this->getItemCollection()->getItems())): ?>
<div class="box-collateral box-up-sell">
<h2><?php echo $this->__('') ?></h2>
<table style=" border:4px solid white;border-right:4px solid green class="mini-products-grid" id="upsell-product-table">
<?php // $this->setColumnCount(5); // uncomment this line if you want to have another number of columns. also can be changed in layout ?>
<?php $this->resetItemsIterator() ?>
<?php for($_i=0;$_i<$this->getRowCount();$_i++): ?>
<tr style="white";>
<?php for($_j=0;$_j<$this->getColumnCount();$_j++): ?>
<?php if($_link=$this->getIterableItem()): ?>
<td style=" border-top:4px solid white;border-right:4px solid green>
<a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_link->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_link, 'small_image')->resize(250) ?>" width="170" height="170" alt="<?php echo $this->escapeHtml($_link->getName()) ?>" /></a>
<h3 class="product-name"><a href="<?php echo $_link->getProductUrl() ?>" title="<?php echo $this->escapeHtml($_link->getName()) ?>"><?php echo $this->escapeHtml($_link->getName()) ?></a></h3>
<?php echo $this->getPriceHtml($_link, true, '-upsell') ?>
<?php echo $this->getReviewsSummaryHtml($_link) ?>
</td>
<?php else: ?>
<td class="empty"> </td>
<?php endif; ?>
<?php endfor; ?>
</tr>
<?php endfor; ?>
</table>
<script type="text/javascript">decorateTable('upsell-product-table')</script>
</div>
<?php endif ?>
我有想法使用正则表达式。
答案 0 :(得分:0)
您可以使用
过滤产品链接集->addAttributeToFilter('name', array('like' => '%Decor%'))
但是你应该在加载集合之前在视图块中执行此操作