2013-10-19 78 views
3

我是Magento Go的新手,我想在產品說明頁面中有兩個自定義字段:功能和規格。看起來我需要使用「自定義屬性」來實現這一點,所以我這樣做了,但是自定義屬性不會顯示在產品頁面中?我如何製作它,以便它出現在產品頁面中?在產品頁面顯示自定義屬性?

回答

2

當你創建自定義屬性「可見在產品視圖頁面上前端」這個選項設置爲YES,它會顯示產品頁面上的屬性...

1

有幾種方法可以打印產品的自定義屬性如下:

1. $getPrdocutData = $_product->getData(); 

這會給你的所有產品的數組屬性,因此你可以使用它。

2. $attributes = $product->getAttributes(); 
    foreach ($attributes as $attribute) { 
     if ($attribute->getIsVisibleOnFront()) { 
     $value = $attribute->getFrontend()->getValue($product); 
     // do something with $value here 
     } 
    } 

3. $productAttrs = Mage::getResourceModel('catalog/product_attribute_collection'); 
    foreach ($productAttrs as $productAttr) { 
     /** $productAttr Mage_Catalog_Model_Resource_Eav_Attribute */ 
     var_dump($productAttr->getAttributeCode()); 
    } 

請再試上面的代碼段,以顯示產品屬性。

+0

由於我使用Magento Go,我不認爲我可以修改PHP代碼,我可以嗎? – Bonk

+0

您可以在主題模板中使用上述代碼之一,產品詳細信息頁面位於app/design/frontend/default/your_theme/template/catalog/product/view.phtml中,同時確保將屬性設置爲顯示在前端在管理員中添加/編輯屬性部分 –

1

產品頁面上添加代碼顯示產品的所有屬性 定義屬性必須適用的可選產品視圖頭版上設置是:

<?php echo $this->getLayout()-> 
     createBlock('catalog/product_view_attributes', '', 
     array('template'=> 'catalog/product/view/attributes.phtml'))->toHtml(); 
?> 

你可能會選擇difine屬性使用此代碼:

$Designer = Mage::getModel('catalog/product')->load($_product->getId())-> 
getAttributeText('manufacturer'); 


<?php if($Designer): ?> 
     <div class="details"><p><span>Designer:</span> 
<?php echo Mage::getModel('catalog/product')->load($_product->getId())-> 
     getAttributeText('manufacturer'); 
?></p></div> 
<?php endif; ?> 
1

要顯示產品頁面上的屬性,你需要添加下面的view.phtml文件中的代碼內容。

<?php echo $_product->getResource()->getAttribute('brand_info')->getFrontend()->getValue($_product); ?> 
+0

這對我來說很重要.. –

相關問題