Magento Entwicklung
Aus Vosp.info
Inhaltsverzeichnis
Entwicklung
- how-to-create-a-new-product-type-in-magento
- How To Create a Featured Product
- Jquery in Magento einbinden
globale Funktionsaufrufe
dieses sind allgemeine Funktionsaufrufe, die nahe zu überall (oder Kontex bezogen) aufgerufen werden können
/**
* hole _POST und _GET Variablen
*/
$post_get_array = Mage::app()->getRequest();
/**
* hole aktuelle Session
*/
$session = Mage::getSingleton('checkout/session');
Model
/**
* product laden
*/
$product = Mage::getModel("catalog/product");
$product = $product->load($param_id)->getData();
// zeige max() eines query
$quote = Mage::getSingleton('checkout/session')->getQuote();
$collection = Mage::getModel('sales/quote_item')->getCollection();
$string_sql = $collection->getSelect()->reset(Zend_Db_Select::COLUMNS)->columns('max(item_id) as last_item_id')
->where("quote_id = ".$quote->getId());
$lastItemId = $collection->getData();
D::s($collection->getData(), '$maxItemId: '.$lastItemId[0]['last_item_id']);
Frontend: Warenkorb
/**
* hole aktuellen Quote (Angebot)
*/
$quote = Mage::getSingleton('checkout/session')->getQuote();
/**
* wenn mensch ein Posten im Warenkorb bearbeitet, kann sich über die Url=/checkout/cart/configure/id/751/ (_GET) die aktuelle Item ID geholt werden
*/
$getParamId = Mage::app()->getRequest()->getParam('id')
Block .... schnipsel
{{block type=”catalog/product_list” category_id=”[Ihre Kategorie ID]” template=”catalog/product/list.phtml”}}
Frontend Beispiele
Unterkategorien einer Kategorie inklusive Bilder und Beschreibung anzeigen
1. Statischen Block anlegen (Backend > CMS > Statische Blöcke >> Neuer Block
Blocktitel: subcategory_listing_full Interner Bezeichner: subcategory_listing_full Status: Aktiviert Inhalt (WYSIWYG Editor ausschalten): eine der folgenden Aufrufe eingen
Vorlage:Block type="catalog/navigation"template="catalog/navigation/subcategory listing full.phtml" Vorlage:Block type="catalog/navigation" category id="8" template="catalog/navigation/subcategory listing full.phtml" Vorlage:Block type="catalog/navigation" category id="8" only name="1" template="catalog/navigation/subcategory listing full.phtml"
app/design/frontend/<<OWNDESIGN>>/default/template/catalog/navigation/subcategory_listing_full.phtml
<div id="categories" class="listing">
<?php
$_maincategorylisting = $this->getCurrentCategory();
$layer = Mage::getSingleton('catalog/layer');
/**
* category_id="X" im Blockaufruf angegeben wurde, dann nimm diese Kategorie als Grundlage
* {{block type="catalog/navigation" category_id="8" template="catalog/navigation/subcategory_listing_full.phtml"}}
*/
if($this->getCategoryId()) {
$paramCategory = Mage::getModel('catalog/category')->load($this->getCategoryId());
$this->setCurrentCategory($paramCategory);
$layer->setCurrentCategory($paramCategory);
}
$_categories = $this->getCurrentChildCategories();
$_helper = $this->helper('catalog/output');
?>
<?php if(count($_categories)):?>
<?php foreach ($_categories as $_category):?>
<?php if($_category->getIsActive()): ?>
<?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer->setCurrentCategory($cur_category);
$catName = $this->getCurrentCategory()->getName();
?>
<?php if(!$this->getOnlyName() && $_imageUrl=$this->getCurrentCategory()->getImageUrl()):?>
<div class="category-image"><a href="<?php echo $this->getCategoryUrl($_category)?>"><img src="<?php echo $_imageUrl?>" height="188"></a></div>
<?php endif;?>
<div class="category-name"><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></div>
<?php if(!$this->getOnlyName() && $_description=$this->getCurrentCategory()->getDescription()): ?>
<div class="category-description"><?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?></div>
<?php endif; ?>
<?php endif; ?>
<?php endforeach?>
<?php
if($this->getCategoryId()) {
$this->setCurrentCategory($_maincategorylisting);
}
$layer->setCurrentCategory($_maincategorylisting);
?>
<?php endif;?>
</div>
- Quellen
Blog-Hints aktivieren
Admin > System > Konfiguration > Entwickleroptionen > obenlinks "Aktueller Konfig.-Bereich" > Main Website
- Debug
- Vorlagen Pfadhinweise: Ja
- Blocknamen zu Hinweisen hinzufügen: Ja
Magento-Themes einfacher erstellen und modifizieren
cd Magento18/
cp -r app/design/frontend/base/default app/design/frontend/default/my_theme
cd app/design/frontend/default/my_theme
find -type f -exec rename -n 's/$/-disabled/' '{}' ';' # simulation
find -type f -exec rename 's/$/-disabled/' '{}' ';'
cd ../../../../../../Magento18/
cp -r skin/frontend/base/default/ skin/frontend/default/my_theme/
cd skin/frontend/default/my_theme/
find -type f -exec rename -n 's/$/-disabled/' '{}' ';' # simulation
find -type f -exec rename 's/$/-disabled/' '{}' ';'
cp app/design/frontend/default/my_theme/template/catalog/product/view.phtml-disabled app/design/frontend/default/my_theme/template/catalog/product/view.phtml