我在主頁上顯示帶有滑塊圖像的所有制造商。在那裏我把查看全部鏈接,點擊鏈接它的顯示所有制造商在新帕赫作爲類別頁面。 我創建manufacturer.php作爲下在magento中創建自定義工具欄獲取錯誤調用非對象的成員函數setCurPage()
<?php
class Bc_Manufacturer_Block_Manufacturerpage extends Mage_Core_Block_Template
{
public function _prepareLayout()
{
return parent::_prepareLayout();
}
public function getManufacturer()
{
if (!$this->hasData('manufacturer')) {
$this->setData('manufacturer', Mage::registry('manufacturer'));
}
return $this->getData('manufacturer');
}
public function getToolbarHtml() {
$this->setToolbar($this->getLayout()->createBlock('catalog/product_list_toolbar', 'Toolbar'));
$toolbar = $this->getToolbar();
$toolbar->enableExpanded();
$toolbar->setAvailableOrders(array(
'ordered_qty' => $this->__('Position'),
'name' => $this->__('Name'),
'price' => $this->__('Price')
))
->setDefaultDirection('desc')
->setCollection($this->_productCollection);
$pager = $this->getLayout()->createBlock('page/html_pager', 'Pager');
$pager->setCollection($this->_productCollection);
$toolbar->setChild('product_list_toolbar_pager', $pager);
return $toolbar->_toHtml();
}
}
又撥打了getToolbarHtml()函數在manufacurerpage.phtml文件作爲下 getToolbarHtml()?>
<div class="grid-type-full">
<?php foreach($maufacturers as $manufacturer): ?>
<?php if(Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName())): ?>
<?php if ($i++%$_columnCount==0): ?>
<ul class="products-grid">
<?php endif ?>
<li style="position: relative; float: left; display: inline-block; " class="item<?php if(($i-1)%$_columnCount==0): ?> first<?php elseif($i%$_columnCount==0): ?> last<?php endif; ?>">
<a href="<?php echo $this->getBaseUrl()."catalogsearch/advanced/result/?manufacturer[]=".$manufacturer->getMenufecturerName() ?>">
<?php echo $this->getLayout()->createBlock('core/template')->setmanufacturerimage($manufacturer->getFilename())->setlegend($manufacturer->getLegend())->setListPageFlag(1)->setTemplate('manufacturer/manufacturer_resize.phtml')->toHtml(); ?>
<div class="manufacturer-name">
<?php echo Mage::getModel('eav/entity_attribute_source_table')->setAttribute(Mage::getModel('eav/entity_attribute')->load(Mage::getModel('eav/entity_attribute')->getIdByCode('catalog_product',"manufacturer")))->getOptionText($manufacturer->getMenufecturerName()) ?>
</div>
</a>
</li>
<?php if ($i%$_columnCount==0 && $i!=count($maufacturers)): ?>
</ul>
<?php endif ?>
<?php endif ?>
<?php endforeach ?>
<script type="text/javascript">decorateGeneric($$('ul.products-grid'), ['odd','even','first','last'])</script>
</div>
<div class="toolbar-bottom">
<?php echo $this->getToolbarHtml() ?>
</div>
運行此我後得到的錯誤如下
致命錯誤:調用成員函數setCurPage()在C:\ wamp \ www \ magento \ jumbos中的非對象撕毀\程序\代碼\核心\法師\目錄\塊\產品\目錄\ Toolbar.php上線225
任何一個有此解決方案,請幫我...
謝謝你..