I have declared a static block in Magento named 'subcategory_listing' that has the following code:

{{block type="subcategory/listing" name="subcategory.listing"  template="category/subcategory.listing.phtml"}}

This block is set on Category View as Display Setings->Static Block Only -> Subcategory Listing (my block) and it has to display all subcategories. The problem is When I have Blocks HTML output enabled. In this situation my block displays the same output when i change categories:

if I get first in Category 1, I get:
Ex: Category 1: Subcategories from category 1
Category 2: Subcategory from Category 1

if I get first in Category 2, I get:
Category 2: Subcategories from category 2
Category 1: Subcategory from Category 2

I've read that it is a cache problem but I can't get it. Any ideas?



<?php $count = 0; ?>
    <?php foreach ($subcategories as $subcategory) { ?>
        <div class="row section main_prod_section <?php echo (++$count%2 ? "reg_bg" : "text-right grey_bg");  ?>">
            <div class="col-sm-6 prod_image_wrapper">
                <img src="<?php echo Mage::getBaseUrl('media').'catalog/category/'.$subcategory->getListingImage(); ?>" alt="<?php echo $subcategory->getName()?>" class="pr_img">
            <div class="col-sm-6 info_wrapper vertical-center">
                <h2 class="title"><?php echo $subcategory->getName()?></h2>
                <p><?php echo $subcategory->getDescription() ?></p>
                <a href="<?php echo $subcategory->getUrl() ?>" class="main_btn">Descoperă</a>
        </div> <!-- end section -->
    <?php } ?>
  • What's in the template file? – Yiorgos Moschovitis Oct 25 '17 at 10:00
  • Please see the UPDATE. – ana.coman93 Oct 25 '17 at 10:42
  • Do you have the block cache turned on? – Yiorgos Moschovitis Oct 25 '17 at 11:30
  • I've Tried to add ` protected function _construct() { $this->addData(array( 'cache_lifetime' => 3600, 'cache_tags' => array(Mage_Cms_Model_Block::CACHE_TAG,Mage_Catalog_Model_Category::CACHE_TAG), 'cache_key' => Mage::registry('current_category')->getId(), )); }` and dosn't displays anything at all. – ana.coman93 Oct 25 '17 at 12:05
  • All caches are enabled – ana.coman93 Oct 25 '17 at 12:06

Your Answer

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

Browse other questions tagged or ask your own question.