cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 1.9: Get Up-sell products in the table, аs select according to product name

Magento 1.9: Get Up-sell products in the table, аs select according to product name

Can I filter, how the Up-sell products /which I have set for a particular product/ will be displayed in my table according to the name of the product? My idea is to display only the products starting with a certain word, such as "Decor", the rest products do not show in the table. This is my code 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">&nbsp;</td>
            <?php endif; ?>
        <?php endfor; ?>
        </tr>
    <?php endfor; ?>
    </table>
    <script type="text/javascript">decorateTable('upsell-product-table')</script>
</div>
<?php endif ?>

 I had an idea to use Regular Expressions. Can anybody help me! Thank you!