我一直在编写自定义向上销售相关产品脚本,该脚本显示 4 个随机产品。
问题是:
正常的产品网址是:
/shop/$产品名称
这有时会生成像这样的 url:/$productname/
或类似网址:/catalog/product/view/id/$productID/4/s/$productname/category/$categoryid/
我想让我的所有网址都一样:/shop/$productname
<div class="upsell">
<h2>You might be interested in</h2>
<?php // List mode ?>
<?php $_iterator = 0; ?>
<?php // Grid Mode ?>
<table class="products-grid upsell" id="upsell-product-table">
<tbody>
<tr>
<?php $_collectionSize = $_productCollection->count() ?>
<?php $_columnCount = $this->getColumnCount(); $_columnCount=4; ?>
<?php $i=0; foreach ($_productCollection as $_product): ?>
<?php if ($i++%$_columnCount==0): ?>
<?php endif ?>
<td>
<?php // Initiate product model
$product = Mage::getModel('catalog/product');
// Load specific product whose tier price want to update
$product ->load($_product->getId()); ?>
<a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($this->getImageLabel($product, 'small_image'), null, true) ?>" class="product-image"><img src="<?php echo $this->helper('catalog/image')->init($product, 'small_image')->resize(170); ?>" width="125" height="125" alt="<?php echo $this->stripTags($this->getImageLabel($_product, 'small_image'), null, true) ?>" /></a>
<h3 class="product-name"><a href="<?php echo $product->getProductUrl() ?>" title="<?php echo $this->stripTags($product->getName(), null, true) ?>"><?php echo $_helper->productAttribute($product, $product->getName(), 'name') ?></a></h3>
<?php echo $this->getPriceHtml($product, true) ?>
</td>
<?php endforeach; ?>
</tr>
</tbody>
</table>
</div>