Magento Entwicklung: Unterschied zwischen den Versionen

Aus Vosp.info
Wechseln zu:Navigation, Suche
(Unterkategorien einer Kategorie inklusive Bilder und Beschreibung anzeigen)
Zeile 76: Zeile 76:
 
<source lang="php">
 
<source lang="php">
 
<div id="categories" class="listing">
 
<div id="categories" class="listing">
<?php $_maincategorylisting=$this->getCurrentCategory()?>                      
+
<?php
<?php $_categories=$this->getCurrentChildCategories()?>
+
<?php  $_helper   = $this->helper('catalog/output'); ?>
+
$_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 if(count($_categories)):?>
 
<?php foreach ($_categories as $_category):?>
 
<?php foreach ($_categories as $_category):?>
 
<?php if($_category->getIsActive()): ?>
 
<?php if($_category->getIsActive()): ?>
 
<?php
 
<?php
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
+
$cur_category=Mage::getModel('catalog/category')->load($_category->getId());
$layer = Mage::getSingleton('catalog/layer');
 
 
$layer->setCurrentCategory($cur_category);
 
$layer->setCurrentCategory($cur_category);
 
$catName = $this->getCurrentCategory()->getName();  
 
$catName = $this->getCurrentCategory()->getName();  
 
?>
 
?>
<?php if($_imageUrl=$this->getCurrentCategory()->getImageUrl()):?>
+
<?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>
 
<div class="category-image"><a href="<?php echo $this->getCategoryUrl($_category)?>"><img src="<?php echo $_imageUrl?>" height="188"></a></div>
<div class="category-name"><a href="<?php echo $this->getCategoryUrl($_category)?>"> <?php echo $_category->getName()?></a></div>
 
 
<?php endif;?>
 
<?php endif;?>
<?php if($_description=$this->getCurrentCategory()->getDescription()): ?>
+
<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>
 
<div class="category-description"><?php echo $_helper->categoryAttribute($_category, $_description, 'description') ?></div>
 
<?php endif; ?>
 
<?php endif; ?>
 
<?php endif; ?>
 
<?php endif; ?>
 
<?php endforeach?>
 
<?php endforeach?>
<?php $layer->setCurrentCategory($_maincategorylisting);  ?>  
+
<?php
 +
if($this->getCategoryId()) {
 +
$this->setCurrentCategory($_maincategorylisting);
 +
}
 +
$layer->setCurrentCategory($_maincategorylisting);   
 +
?>  
 
<?php endif;?>
 
<?php endif;?>
 
</div>
 
</div>
  
 
</source>
 
</source>
 +
 
== Blog-Hints aktivieren ==
 
== Blog-Hints aktivieren ==
  

Version vom 5. März 2014, 01:39 Uhr

Entwicklung

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

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>

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