Dez 29 2009

Mage_Catalog_Block_Product_List nutzen

Category: Magentoc0d1ngl4m4 @ 13:51

Productlisting mit speziellen Produkten:

1
2
3
4
5
6
<?php
class MyModule_Block_Glossy_Show extends Mage_Catalog_Block_Product_List
{
...
}
?>

Template XML:

1
2
3
4
5
<catalog_glossary_show>
	<reference name="content">
		<block type="mymodule/glossary_show" name="glossary.show" template="glossary/show.phtml" />
	</reference>
</catalog_glossary_show>

Mein Controller :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php
class MyModule_Catalog_GlossaryController extends Mage_Core_Controller_Front_Action {
 
[...]
public function showAction()
{
	[...]
	$products = Mage::getModel('catalog/product')
		->getCollection()
		->addAttributeToSelect('*')
		->addFieldToFilter('specialstuff', $id)
		->load();
 
	$this->loadLayout();
	$this->getLayout()->getBlock('glossary.show')->setCollection($products);  // Here is the magic!! 
	$this->renderLayout();
	//die ("SHOW ACTION");
}
?>

Das .phtml File ist einfach Copy&Paste vom Original Product Listing in magento.
Da bei mir noch einige Spezielle Dinge passieren nehme ich nicht das Original Template.
In der Layout XML könnt ihr aber einfach das Template von glossary/show.phtml nach catalog/product/list.phtml ändern.

Schlagwörter: , ,


Get Adobe Flash playerPlugin by wpburn.com wordpress themes