1

I have multiple stores in my Magento. For each store I have created a home page in CMS > Pages > Manage pages. At the design tab I use this layout update XML code:

<reference name="content">
<block type="catalog/product_new" name="home-categories" template="custom/category_grid.phtml" after="-"/>

<!--
<block type="catalog/product_list" name="product_list" template="catalog/product/list.phtml">
<action method="setColumnCount"><columns>4</columns></action>
</block>
-->
</reference>

The result of including this code in the layout update XML textarea is that each category will be displayed at the homepage. See screenshots below:

Here the categories are working: (the <ul> tag is included in the html) enter image description here

Here the categories aren't working: (the <ul> tag is not included in the html)

enter image description here

The problem is that one store doesn't show the categories in the grid. I think that the solution to this problem lays somewhere else but I don't know where to look. Where can I look?

Update

The code of function getSelectSQL in "lib\Varien\Data\Collection\Db.php"

function getSelectSql($stringMode = false)
    {
        if ($stringMode) {
            return $this->_select->__toString();
        }
        return $this->_select;
    }
  • The <!-- [...] --> means that it is inactive. So including this code shouldn't result in a grid. My guess is that the grid is coming from somewhere else – Sander Mangel Apr 30 '15 at 13:21
  • @Sander please see my code update – Julian Apr 30 '15 at 13:22
1

You are using block type catalog/product_new, but you are outputting with template category_grid. According to your question it sounds like you are trying output category collection. But in your block definition in section type you are trying to get PRODUCT COLLECTION.

Please clarify your goal. What do you need to output? Categories or products?

And i'd like to draw your attention on method _getProductCollection(). It has following rows:

        ->addAttributeToFilter('news_from_date', array('or'=> array(
            0 => array('date' => true, 'to' => $todayEndOfDayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')
        ->addAttributeToFilter('news_to_date', array('or'=> array(
            0 => array('date' => true, 'from' => $todayStartOfDayDate),
            1 => array('is' => new Zend_Db_Expr('null')))
        ), 'left')

If you have no products, created during this period - you'll get empty result.

  • 1
    I can't even imagine what do you want to output. Categories have tree structure. To get categories collection - use your own category collection. Here are some examples how to get it: magento.stackexchange.com/questions/9411/… And most probably you know what to output, as you have some custom/category_grid template – zhartaunik Apr 30 '15 at 14:09
  • You mean that the described code is working properly on one store. Ok, show please $collection->getSelectSQL(1) before return. And also show the template code – zhartaunik Apr 30 '15 at 19:31
  • Please see the update – Julian May 1 '15 at 6:52
  • I know the code of getSelectSQL method.... I looked for result of your collection. – zhartaunik May 1 '15 at 8:07
  • I found the solution which was to add the category id of the webshop in category_grid.phtml – Julian May 1 '15 at 10:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.