I need to develop a landing page with products from different categories. Something like:
Banner
Products from category 1
Banner
Products from category 2
I'm trying to do it like this:
Banner
{{block type="catalog/product_list" name="cat1" id="cat1" category_id="1" template="catalog/product/list.phtml"}}
Banner
{{block type="catalog/product_list" name="cat2" id="cat2" category_id="2" template="catalog/product/list.phtml"}}
But it is not working. It works when I test with only category, but the moment I add the second block it doesn't display anything.
Is there any limit using the same block more than once in the same CMS Page?
I have also tried creating a Static CMS block with each block and then add the widgets to the CMS Page but the result is the same, well, in this case it is displaying the first block but not the second one.
I have also tried changing the layout but result is the same, with one block is ok, it is work but with 2 blocks it is not displaying anything.
Any ideas?
I'm in Magento EE1.13.0.2.
Update:
If I try with the layout like this:
<reference name="content">
<block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>1</category_id></action>
</block> <block type="catalog/product_list" name="featured" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
</block> </reference>
Doing it with layers display the 2 blocks but repeated! So both blocks are displaying the category 2. It seems like a product list block can be used only once per page?
Update 2:
ok, so to prevent this, you need to give a diferent name to each block:
<reference name="content">
<block type="catalog/product_list" name="featured_1" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>1</category_id></action>
</block> <block type="catalog/product_list" name="featured_2" template="catalog/product/list.phtml">
<action method="setCategoryId"><category_id>2</category_id></action>
</block> </reference>
but now the problem is that I get a MySQL error:
SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1
Trace:
#0 /public_html/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
#1 /public_html/app/code/core/Zend/Db/Statement.php(291): Varien_Db_Statement_Pdo_Mysql->_execute(Array)
#2 /public_html/lib/Zend/Db/Adapter/Abstract.php(479): Zend_Db_Statement->execute(Array)
#3 /public_html/lib/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('SELECT `mage_ca...', Array)
#4 /public_html/lib/Varien/Db/Adapter/Pdo/Mysql.php(428): Zend_Db_Adapter_Pdo_Abstract->query('SELECT `mage_ca...', Array)
#5 /public_html/lib/Zend/Db/Adapter/Abstract.php(753): Varien_Db_Adapter_Pdo_Mysql->query(Object(Varien_Db_Select), Array)
#6 /public_html/app/code/core/Mage/Core/Model/Resource/Db/Abstract.php(380): Zend_Db_Adapter_Abstract->fetchRow(Object(Varien_Db_Select))
#7 /public_html/app/code/core/Mage/Core/Model/Abstract.php(225): Mage_Core_Model_Resource_Db_Abstract->load(Object(Mage_Catalog_Model_Category), Object(Mage_Catalog_Model_Category), NULL)
#8 /public_html/app/code/core/Mage/Catalog/Block/Product/List.php(80): Mage_Core_Model_Abstract->load(Object(Mage_Catalog_Model_Category))
#9 /public_html/app/code/core/Mage/Catalog/Block/Product/List.php(142): Mage_Catalog_Block_Product_List->_getProductCollection()
#10 /public_html/app/code/core/Mage/Core/Block/Abstract.php(885): Mage_Catalog_Block_Product_List->_beforeToHtml()
#11 /public_html/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#12 /public_html/app/code/core/Mage/Core/Block/Abstract.php(886): Mage_Core_Block_Text_List->_toHtml()
#13 /public_html/app/code/core/Mage/Core/Block/Abstract.php(605): Mage_Core_Block_Abstract->toHtml()
#14 /public_html/app/code/core/Mage/Core/Block/Abstract.php(549): Mage_Core_Block_Abstract->_getChildHtml('content', true)
#15/public_html/app/design/frontend/novaworks/bearstore/template/page/1column.phtml(60): Mage_Core_Block_Abstract->getChildHtml('content')
#16 /public_html/app/code/core/Mage/Core/Block/Template.php(241): include('/...')
#17 /public_html/app/code/core/Mage/Core/Block/Template.php(272): Mage_Core_Block_Template->fetchView('frontend/novawo...')
#18 /public_html/app/code/core/Mage/Core/Block/Template.php(286): Mage_Core_Block_Template->renderView()
#19 /public_html/app/code/core/Mage/Core/Block/Abstract.php(886): Mage_Core_Block_Template->_toHtml()
#20 /public_html/app/code/core/Mage/Core/Model/Layout.php(555): Mage_Core_Block_Abstract->toHtml()
#21 /public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(390): Mage_Core_Model_Layout->getOutput()
#22 /public_html/app/code/core/Mage/Cms/Helper/Page.php(137): Mage_Core_Controller_Varien_Action->renderLayout()
#23 /public_html/app/code/core/Mage/Cms/Helper/Page.php(52): Mage_Cms_Helper_Page->_renderPage(Object(Mage_Cms_PageController), '122')
#24 /public_html/app/code/core/Mage/Cms/controllers/PageController.php(45): Mage_Cms_Helper_Page->renderPage(Object(Mage_Cms_PageController), '122')
#25 /public_html/app/code/core/Mage/Core/Controller/Varien/Action.php(418): Mage_Cms_PageController->viewAction()
#26 /public_html/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(250): Mage_Core_Controller_Varien_Action->dispatch('view')
#27 /public_html/app/code/core/Mage/Core/Controller/Varien/Front.php(172): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#28 /public_html/app/code/core/Mage/Core/Model/App.php(354): Mage_Core_Controller_Varien_Front->dispatch()
#29 /public_html/app/Mage.php(683): Mage_Core_Model_App->run(Array)
#30 /public_html/index.php(166): Mage::run('', 'store')
#31 {main}
Thanks!