Frage

Ich versuche zu überschreiben Core/Katalog/Block/Produkt/list.php mit folgendem

Ref:http://www.magentocommerce.com/boards/viewthread/14692/

Datei: Ziva/CustomCatalog/etc/config.xml

<config>
    <modules>
        <Ziva_CustomCatalog>
            <version>1.0.0</version>
        </Ziva_CustomCatalog>
    </modules>
    <global>
        <blocks>
            <catalog>
                <class>Ziva_CustomCatalog_Block</class> <!--this is a new block page for that custom module-->
                <rewrite>
                    <product_list>Ziva_Customcatalog_Block_Product_List</product_list>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

Datei: ZIVA/CustomCatalog/Block/Produkt/list.php

class Ziva_Customcatalog_Block_Product_List extends Mage_Catalog_Block_Product_List {

    public function __construct() {
        parent::__construct();
    }

    protected function _getProductCollection() { // trying to override this method
        echo __CLASS__;
        return parent::_getProductCollection();
    }

    public function holdthis() {
        echo __METHOD__;
    }

}

In Ausnahmeprotokoll bekomme ich

exception 'Mage_Core_Exception' with message 'Invalid block type: Ziva_CustomCatalog_Block_Product_Compare_Sidebar' in C:\wamp\www\magento2\app\Mage.php:594

gefolgt von

Invalid block type: Ziva_CustomCatalog_Block_Product_Price_Template
Invalid block type: Ziva_CustomCatalog_Block_Layer_View
Invalid block type: Ziva_CustomCatalog_Block_Category_View
Invalid block type: Ziva_CustomCatalog_Block_Product_List_Toolbar

Und es werden keine Produkte angezeigt

BEARBEITEN:

Ich dachte das Problem

<class>Ziva_Customcatalog_Block</class>

Jetzt setze ich die Frage um.

In einem benutzerdefinierten Modul können Sie nur eine Blockklasse haben? Aber in Kern/Katalog/Block, Wir können viele sehen.

War es hilfreich?

Lösung

Wenn Sie Ihre config.xml wie folgt aktualisieren, sollten Sie mehrere eindeutige Handles hinzufügen können:

<config>
    <modules>
        <Ziva_CustomCatalog>
            <version>1.0.0</version>
        </Ziva_CustomCatalog>
    </modules>
    <global>
        <blocks>
            <ziva_customcatalog>
                <class>Ziva_CustomCatalog_Block</class> <!--this is a new block page for that custom module-->
            </ziva_customcatalog>
            <catalog>
                <rewrite>
                    <product_list>Ziva_Customcatalog_Block_Product_List</product_list>
                </rewrite>
            </catalog>
        </blocks>
    </global>
</config>

Sie können dann anrufen 'ziva_customcatalog/layer_view' Für Ihren neuen Block.

Andere Tipps

Passt auf:

<product_list>Ziva_Customcatalog_Block_Product_List</product_list>

Muss in einer Linie ohne Leerzeichen sein! Ich wurde verrückt, ein ähnliches Problem zu lösen!

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit magento.stackexchange
scroll top