Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

How to I setup flat catalog data? 
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

When I set up my magento store it was orginally set not to use flat catalog data.
I have imported 40000 categories and I am currently getting slow web page load speeds
about 20 sec per page on first visit.
To help and try to improve performance I want to turn on flat catalog data.
What I have done is:
1) clear cache
2) enabled Use Flat Catalog Category (under system->configuration->catalog->frontend)
3) reindex everything under index management and also tried to reindex Category Flat Data only

When I try to the view the site all the categories are gone and only half the page loads
if I turn Use Flat Catalog Category off all the catagories reappear but the pages load but jus very slowly again.

Any help on resolving this issue would be great.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

I think the half the page loads because there is a ‘fatal error’ someware.
Activate the logging (System->configuration->Developer->Logging).
Try using the flat categories again.
If the issue is reproduced then check the var/log folder for more details. Write here the error you are getting.
Your page could be slow because you are trying to show all 40000 categories at once.
I assume you don’t want all the categories listed in the menu at once. (If you do I don’t think I have a solution for you).
Limit the level of categories listed in the menu.
(System->Configuration->Catalog->Category Top Navigation and change the field ‘Maximal Depth’).

Marius.

 
Magento Community Magento Community
Magento Community
Magento Community
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

Hi tzyganu
Thanks for the reply

I am not trying to show al categories in one go
below is an exmaple of the structure for only 1 model of car

default category
-> SElect manufacturer (level 1)
->audi (level 2)
->A1 2010 (level 3)
->A1 1.2 TFSi08|10- (level 4)
->Front Brake Discs (level 5)
->Rear Brake Discs (level 5)
->Front Brake Pads (level 5)
->Rear Brake Discs (level 5)
->Brake Kits(level 5)

I have added a script that only pulls out the
categories for that level. So the first link only shows
select manufacturer then when clicked it will only show its subcategories etc..

All my categories are set not to show in Navigatoin menu.
And even the display on the homepage which has a normal html link
that I created to the level 1 category takes time to load the
first time round. But if someone views it on another pc it
will load fast, the issue only appears to occur the first time the
page loads. My host has advised it has to do with the way magento only partially cache data.

I have enabled logging and turned on flat categories issue perists but no log file or folder within the vat folder to check.

Thanks

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

I’m sorry but I have nothing to work with. Is your website public? Can you provide an url?

 
Magento Community Magento Community
Magento Community
Magento Community
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

Sure here is the test site I am currently working on

http://brakes.terrassldev.co.uk/

No products have been added yet but the categories have.

This is with flat catalog on

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

I see that the page stops loading right under the title of the category.
I think there is an error in your php log. Some fatal error. That’s why it doesn’t appear in the Magento log.
I think there is an issue in one of your blocks.

 
Magento Community Magento Community
Magento Community
Magento Community
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

I have updated with flat catalog turned of so
you can see the way its actually supposed to work

I have only added 1 additional block so I will need to check that

<?php $_categories=$this->getCurrentChildCategories(); ?>
<br>

<
div class="category-products">
<?php $_collectionSize $_categories->count() ?>
    
<table class="products-grid" id="products-grid-table">
     <
tr>
     <
td width="300">
     
<?php $i=0; foreach ($_categories as $_category): ?>
     
<a href="<?php echo $_category->getURL() ?>" title="<?php echo $this->htmlEscape($_category->getName()) ?>">
 
<?php echo $this->htmlEscape($_category->getName()) ?></a><br />
<?php $i++; ?>
 <?php 
if ($i==20): ?>
</td><td width="300">
<?php $i=0?>
<?php 
endif ?>
<?php 
endforeach ?>
</td></tr>
                            
    </
table>
</
div>
<
br>

This is the content of the block to pull the categories this works fine when flat catalog turned off

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

In order to get the child categories try this:

if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children 
= (array)$category->getChildrenNodes();
        
else {
            $children 
$category->getChildren();
        
}
and then loop through the $children array.
foreach ($children as $child){
$_category 
Mage::getModel('catalog/category')->load($child->getId());
//do stuff with $_category.
}
To get the category URL call this
$_category->getUrl();
 
Magento Community Magento Community
Magento Community
Magento Community
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

Thanks for the help tzyganu
I’ll try this and let you know how I get on with it

 
Magento Community Magento Community
Magento Community
Magento Community
 
neit
Jr. Member
 
Total Posts:  18
Joined:  2010-06-16
 

Hi
I believe the following code should check to see if flat catalog data is enabled and print out the url for the subcategories of the category I am on, is that correct? If so the page still stops loading as before suggesting there is something wrong with the block.

<?php 
if (Mage::helper('catalog/category_flat')->isEnabled()) {
         $children 
= (array)$category->getChildrenNodes();
        
else {
            $children 
$category->getChildren();
        
}  
        ?>


<br>

<
div class="category-products">
    <
table class="products-grid" id="products-grid-table">
     <
tr>
     <
td width="300">
     
     
     
     
<?php
      
foreach ($children as $child){
          $_category 
Mage::getModel('catalog/category')->load($child->getId());
          
//do stuff with $_category.
           
echo $_category->getUrl();
         
}
         ?>
           
           
           
            
</td></tr>
          </
table>
          </
div>
          <
br>
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top