Praxisbeispiel 3: Die Category-Entität erweitern

In diesem Beispiel erfahren Sie, wie Sie mit einem Installationsskript einer Entität ein neues Attribut hinzufügen können. Die Entität catalog_category soll das neue Attribut color bekommen, in dem ein Farbwert gespeichert werden soll, der dann im Frontend als Hintergrundfarbe genutzt wird.

Eine Setup-Ressource in die config.xml eintragen

Damit Magento Installations- und Upgrade-Skripte eines Moduls ausführt, wird eine Setup-Resource in der <global>-Sektion der config.xml benötigt.

<resources>
    <helloworld_setup>
        <setup>
            <module>Webkochshop_HelloWorld</module>
            <class>Mage_Catalog_Model_Resource_Eav_Mysql4_Setup</class>
        </setup>
    </helloworld_setup>
</resources>

Der Modulname muss angegeben werden, damit ...

Get Magento: Das Handbuch für Entwickler now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.