2013-06-26 67 views
0

我想在產品詳細信息頁面添加靜態塊4類我不喜歡這個附加在商品詳細頁靜態塊帶有URL和塊標題free_shipping_4。 (free_shipping_4中的4代表類別4)。只對某些類別的

我得到錯誤:

Fatal error: Unsupported operand types in C:\wamp\www\mydomain\app\design\frontend\default\mytheme\template\catalog\product\view.phtml on line 140

+1

線140是什麼樣子? –

+0

'$ this-> helper('catalog/data') - > getProduct() - > getCategoryIds();返回一個包含當前產品關聯的所有類別的ID的數組,而不是一個ID,所以''free_shipping_「+ $ catid'無法工作(我想這是140行)。 – blmage

+0

我正在使用我自己的主題。最初第40行是<?php $ blockID =「product-view-static-links_」。$ catid; ?>但現在我發現$ catid是數組。所以用$ catid [1]它現在正在工作。 – abagray

回答

0

$ CATID = $這 - >輔助( '目錄/數據') - > getProduct() - > getCategoryIds(); ? > getLayout() - > createBlock( 'CMS /塊') - > setBlockId($塊標識) - > toHtml()>

$catid will contain array of id product is associated with. 

我想一個方法是創建一個產品屬性,將包含類別ID需要顯示,然後您可以檢索產品屬性。

<?php $blockID = "free_shipping_" + $productattributevalue ?> 
0

是的你是對的。我發現現在$ catid是一個數組。所以我用 $ catid [1]來獲取目錄ID。所以,我的代碼看起來像這樣

<?php $blockID = "free_shipping_" . $catid[1]?> 
<?php echo $this->getLayout()->createBlock('cms/block')->setBlockId($blockID)->toHtml(); 

要查找的目錄編號,我感興趣的是靜態塊名稱(free_shipping_4)使用我用下面的代碼

SELECT entity_id AS categoryID, value AS categoryName 
    FROM catalog_category_entity_varchar 
    WHERE attribute_id =4 
    LIMIT 0 , 30 

現在就解決了。雖然必須有更好更簡單的方法來做到這一點。