2012-11-16 158 views

回答

1

你可以做這樣的連接產品屬性(例如製造商)與靜態塊。

參見此代碼:

$sizeGuideIdentifier = trim($_product->getAttributeText('manufacturer')); 
$sizeGuideIdentifier = str_replace(' ','-',strtolower($sizeGuideIdentifier)) .'-size-guide'; 

if($this->getLayout()->createBlock('cms/block')->setBlockId($sizeGuideIdentifier)->toHtml()): 

echo $this->getLayout()->createBlock('cms/block')->setBlockId($sizeGuideIdentifier)->toHtml(); 

else: 

echo $this->getLayout()->createBlock('cms/block')->setBlockId('product-sizeguide')->toHtml(); 

endif; 

它將嘗試回聲出一個例如被稱爲塊「nike-sizeguide」,如果這個塊不存在,它會回落到默認的sizeguide。

+0

歐文您好,感謝一噸的回答是不被接受的OP。如果你向我詳細解釋這一點,這將是非常棒的。例如,在何處安裝此代碼以及如何將此代碼集成到產品頁面等等。提前致謝 – formygalaxy

+0

您可以將此代碼段放在產品視圖模板的任何位置:/ magento/app/design/frontend/[packagename]/[templatename] /catalog/product/view.phtml 之後,創建一個靜態塊並將其命名爲product-sizeguide。 如果您想爲特定品牌使用不同的尺寸導標,請使用標識符nike-sizeguide創建尺寸指南。在後臺轉到您的產品,並將製造商設置爲耐克,並且應該選擇耐克特定尺寸指南。 –

+0

謝謝erwin,我沒有設置任何'製造商',我的男士類別是(/men/formal-shirts/regular.html)和女士(女士/上衣/ blouse.html)。根據這個如何改變你的代碼。 – formygalaxy

1

yup,這在Magento 1.9CE上完美運行,儘管對於我來說Erwin的解決方案需要插入到「app/design/frontend /.../.../ template/catalog/product/view/type/options /configurable.phtml」。

真的很簡單的解決方案和偉大的結果;我們現在爲每個品牌(製造商)自動彈出一個fancybox尺寸圖圖像,無需編碼,我們的庫存經理不需要考慮它。

真的非常棒 - 非常感謝Erwin Smit。我希望好人緣訪問了你了;)

<dd <?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>> 
     <div class="input-box"> 
      <select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select"> 
       <option><?php echo $this->__('Choose an Option...') ?></option> 
       </select> 
      </div> 

     <div class="size-box"><?php 
       $sizeGuideIdentifier = trim($_product->getAttributeText('manufacturer')); 
       $sizeGuideIdentifier = str_replace(' ','-',strtolower($sizeGuideIdentifier)) .'-size-guide'; 
       if($this->getLayout()->createBlock('cms/block')->setBlockId($sizeGuideIdentifier)->toHtml()): 
       echo $this->getLayout()->createBlock('cms/block')->setBlockId($sizeGuideIdentifier)->toHtml(); 
       else: 
       echo $this->getLayout()->createBlock('cms/block')->setBlockId('product-sizeguide')->toHtml(); 
      endif;?> 
     </div> 
    </dd> 
相關問題