php - Wrong product URLs magento -
i've been working on custom sells related products script, displaying 4 random products.
problem is:
normal product url is:
/shop/$productname
this generating url like: /$productname/
or url like: /catalog/product/view/id/$productid/4/s/$productname/category/$categoryid/
i want have urls same so: /shop/$productname
<div class="upsell"> <h2>you might 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 $_product): ?> <?php if ($i++%$_columncount==0): ?> <?php endif ?> <td> <?php // initiate product model $product = mage::getmodel('catalog/product'); // load specific product tier price want 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>
try
$this->geturl('shop').$product->geturlpath()
instead of
$product->getproducturl()
for both image , product title.
Comments
Post a Comment