Magento custom block breaks the site. What for?

I am working on a custom block for magento 1.7. I have a block declared as such in my config xml. This module also has a controller defined in it, which works fine. I needed a new block with some logic, so I decided that I would use the module that I had already created. I have included the block declaration below.

<?xml version="1.0" encoding="UTF-8"?> <config> <modules> <Company_Catalog> <version>0.1.0</version> </Company_Catalog> </modules> <global> <blocks> <catalog> <class>Company_Catalog_Block</class> </catalog> </blocks> </global> </config> 

I used the block in local.xml in my theme using this syntax:

 <block type="catalog/featured" name="featuredproducts" before="-" template="catalog/featured.phtml"/> 

The block looks the way I want, but the problem is that most of the rest of the site is broken and exception.log is full magento, looking for other blocks in my module. Examples:

 2012-11-27T19:34:47+00:00 ERR (3): exception 'Mage_Core_Exception' with message 'Invalid block type:Company_Catalog_Block_Product_List' in /home/project/site_content/app/Mage.php:594 2012-11-27T19:34:47+00:00 ERR (3): exception 'Mage_Core_Exception' with message 'Invalid block type: Company_Catalog_Block_Product_List_Toolbar' in /home/project/site_content/app/Mage.php:594 

I do not want to rewrite any existing blocks, just add a new one to the already declared module.

I obviously told Magento to look in my module more than I want. This is my first attempt to work with custom blocks in Magento, so I'm not sure what I'm doing wrong.

I understand that Directory is also used in the Mage namespace, but I work in my own namespace. As far as I understand, there should be no conflict.

thanks

+4
source share
1 answer

You rewrite the prefix of the original source directory block in Mage / Catalog / etc / config.xml:

 <global> <blocks> <catalog> <class>Mage_Catalog_Block 

Thus, each request for a catalog block type="catalog/..." ( type="catalog/..." ) uses the Company_Catalog_Block prefix.

+5
source

All Articles