0
我試圖在父類別的頁面上顯示子類別網格。 我已經按照this教程和一切工作正常,除了即使我已經分配圖像到每個子類別,頁面仍然顯示佔位符圖像,而不是實際的。無法檢索magento子類別圖像
我認爲在phtml代碼的某處存在問題。
// Retrieve the current category and it's children
<?php
$_maincategorylisting=$this->getCurrentCategory();
$_categories=$this->getCurrentChildCategories();
if($_categories->count()):
foreach ($_categories as $_category):
if($_category->getIsActive()):
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
$layer->setCurrentCategory($cur_category);
$catName = $this->getCurrentCategory()->getName();
$_imageUrl=$cur_category->getImageUrl();
if (!$_imageUrl) : //if the image url is false set it to the placeholder
$_imageUrl = $this->getSkinUrl('images/catalog/product/placeholder/thumbnail.jpg');
endif;
/* output */ ?>
<div class="category-box">
<a href="<?php echo $this->getCategoryUrl($_category)?>">
<img src="<?php echo $_imageUrl?>" height="80">
</a>
<p><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></p>
</div>
<?php endif;
endforeach;
$layer->setCurrentCategory($_maincategorylisting);
endif; ?>
注:
我跑Magento的v 1.6.0.0
This是我測試的分類頁面。
我跟着你的建議,但沒有與子類別的圖像 – Bogdan 2012-08-15 10:37:23
改變@Bogdan我和我的隊友嘗試來自教程的代碼,你已經提到併爲我們工作。我們注意到一些不良的PHP風格,如使用<?一些PHP代碼?>而不是<?php ome php code?>。你能告訴我們,你在Magento安裝中有多少商店視圖? – ceckoslab 2012-08-15 11:54:58
另外這裏的代碼是格式良好的一些版本的PHP不會拋出錯誤,因爲這個腳本樣式「 ?>」https://gist.github.com/3359512 – ceckoslab 2012-08-15 12:00:54