2015-05-31 81 views
0

我需要在特定類別內的所有產品的價格附近顯示文本。Magento - 在產品頁面顯示自定義文本,僅適用於特定類別的產品

我發現這個代碼有效,但它只適用於一個特定的類別。 我需要把119,120,121,122等...更多類別ID,不只是一個。

你能幫我嗎?

<?php $category = Mage::getModel('catalog/layer')->getCurrentCategory();?> 
      <?php if($category->getId()==119): ?> 
      <span class="price-specification"> 
      <?php echo $this->__('Price per meter.'); ?><br /> 
      <?php echo $this->__('Sold only in multiples of three.'); ?> 
      </span> 
      <?php endif; ?> 

回答

1

要在1個多具體的類別顯示文本,只需做到以下幾點:

  • 創建要顯示這個文本的所有類別ID的數組。 例如:$ arr = array(19,120,121,122);
  • 已經到位的

    如果($分類 - >的getId()== 119):

把下面的代碼:

if(in_array($category->getId(),$arr)): 

請讓我知道如果你有任何問題。

+0

謝謝你,完美的作品:) –

相關問題