Quantcast
Channel: Magento – Marcel Schmidt Wiki / Neuigkeiten
Viewing all articles
Browse latest Browse all 10

Magento Extension für Data Upgrades über ein Update Script (z.B. bei Verwendung von git)

$
0
0

Im folgenden Beispiel schreiben wir eine kurze Extension, über die z.B. Kategorien angelegt werden oder CMS-Blöcke erstellt und geändert werden können usw. Dies verwendet man oft bei der Verwendung von git oder zur Bereitstellung von Daten für eigene Extensions.

Schritt 1 – Ordner Anlegen
app/code/local/M28visions/Cmsupdate/
app/code/local/M28visions/Cmsupdate/etc/
app/code/local/M28visions/Cmsupdate/data/
app/code/local/M28visions/Cmsupdate/data/cmsupdate_setup/

Schritt 2 – Dateien Anlegen
app/code/local/M28visions/Cmsupdate/etc/config.xml — enthält immer die Konfiguration einer Extension
app/code/local/M28visions/Cmsupdate/data/cmsupdate_setup/data-upgrade-1.0.0.0-1.0.0.1.php — enthält die update daten

app/etc/modules/M28visions_Cmsupdate.xml — am Ende erstellen, zum Aktivieren der Extension

Schritt 3 – Inhate

config.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <M28visions_Cmsupdate>
            <version>1.0.0.1</version>
        </M28visions_Cmsupdate>
    </modules>
    <global>
        <resources>
            <cmsupdate_setup>
                <setup>
                    <module>M28visions_Cmsupdate</module>
                </setup>
            </cmsupdate_setup>
        </resources>
    </global>
</config>

data-upgrade-1.0.0.0-1.0.0.1.php:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
/**
 * M28visions DeineTuer data upgrade script
 */
 
$this->startSetup();
 
/* UPDATE CMS BLOCK */
 
$content = '<h3 class="item" style="width:60px;">&nbsp;</h3>
<h3 class="item"><a href="/xxx.html?n1=new10#limit=20&mode=grid&order=price&dir=asc&p=1&cat[]=36&price[min]=63&price[max]=1096&dt_deliverytime[]=607"><img src="{{media url="wysiwyg/content/header_item2.png"}}" alt="" /></a></h3>
<h3 class="item"><a class="variousBox" data-fancybox-type="ajax" href="/opencmsblog?blog_identifier=option_service"><img src="{{media url="wysiwyg/content/header_item3.png"}}" alt="" /></a></h3>
<h3 class="item icon"><a href="https://www.xxx.de/shop/certificate.php?shop_id=4234" target="_blank"><img src="/media/wysiwyg/images/trusted_shop.png" alt="" /></a></h3>';
 
$block = Mage::getModel('cms/block')->load('header_spezials');
$block->setContent($content);
$block->save();
 
$this->endSetup();

M28visions_Cmsupdate.xml:

1
2
3
4
5
6
7
8
9
<?xml version="1.0"?>
<config>
    <modules>
        <M28visions_Cmsupdate>
            <active>true</active>
            <codePool>local</codePool>
        </M28visions_Cmsupdate>
    </modules>
</config>

Viewing all articles
Browse latest Browse all 10