2015-05-12 27 views
1

我使用foreach循環循環通過與特定的產品在我的「Magento的」商店陣列。 (3470,3471,3472)

此代碼似乎除了每個項目的網址是一樣的首批產品網址工作。

當我把模型加載示例中的一個id值: $ _product = $ model-> load(3471);顯示正確的網址。

但是,當我通過使用$ productid: $ _product = $ model-> load($ productid); 它總是返回每個循環的第一個產品url。

有人知道如何處理這個問題嗎?

我的代碼:

$model = Mage::getModel('catalog/product'); 
$product_ids = array(3470, 3471, 3472); 
foreach ($product_ids as $productid){ 

$_product  = $model->load($productid); 
$link_bundel = $_product->getProductUrl(); 

$content .= <<<EOF 

    <div id="id="bundel-wrapper-{$productid}" class="bundel-wrapper"> 
     <a id="bundel-link-{$productid}" class="bundel-link" href="{$link_bundel}" title="{$_product->getName()}"> 
      <img src="{$_product->getImageUrl()}" title="{$_product->getName()}" /> 
      <div id="specification" class="specification"> 
       <h2>{$_product->getName()}</h2> 
       {$_product->getShortDescription()} 
      </div> 

     </a> 
    </div> 

EOF; 
} 

回答

1

$產品 - > getUrlPath()而不是$產品 - > getProductUrl()

+0

THX的男人,多麼愚蠢我的XD –