dongzuoyue6556 2013-07-31 22:31
浏览 23
已采纳

如何仅使用magento过滤库存产品中的related.phtml

How would one go about filtering magento's related products block to show only in stock products?

    <?php foreach($this->getItems() as $_item): ?>
        <li class="item">
            <?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
                <?php if (!$_item->getRequiredOptions()): ?>
                    <input type="checkbox" class="checkbox related-checkbox" id="related-checkbox<?php echo $_item->getId() ?>" name="related_products[]" value="<?php echo $_item->getId() ?>" />
                <?php endif; ?>
            <?php endif; ?>
            <div class="product">
                <a href="<?php echo $_item->getProductUrl() ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($_item, 'thumbnail')->resize(50) ?>" width="50" height="50" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
                <div class="product-details">
                    <p class="product-name"><a href="<?php echo $_item->getProductUrl() ?>"><?php echo $this->htmlEscape($_item->getName()) ?></a></p>
                    <?php echo $this->getPriceHtml($_item, true, '-related') ?>
                    <?php if ($this->helper('wishlist')->isAllow()) : ?>
                        <a href="<?php echo $this->getAddToWishlistUrl($_item) ?>" class="link-wishlist"><?php echo $this->__('Add to Wishlist') ?></a>
                    <?php endif; ?>
                </div>
            </div>
        </li>
    <?php endforeach ?>

I've uploaded my current iteration of magentos realted.phtml to github:

https://gist.github.com/anonymous/6126772

  • 写回答

1条回答 默认 最新

  • dongzhi4073 2013-07-31 23:04
    关注

    Wrap the <li> in <?php if ($_item->isSaleable()): ?> . . . <?php endif; ?>.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿