0

Block created inside custom module doesn't show up in the fron-end.

Namespace: Fmat

Module: FtPrices

Custom Block file: Fmat/FtPrices/Block/Product/View/Tierprices.php


custom block php file:

<?php
 class Fmat_FtPrices_Block_Product_View_Tierprices extends Mage_Core_Block_Template {
 }
?>

block's definition in module's config.xml (...etc/config.xml)

<global>
(...)
    <blocks>
        <fmat_ftprices>
            <class>Fmat_FtPrices_Block_Product_View_Tierprices</class>
        </fmat_ftprices>
    </blocks>
</global>

in module's layout file:

<catalog_product_view>
    <reference name="product.info">
        <block type="fmat_ftprices/product_view_tierprices" name="product.custom.tierprices" as="custom_tierprices" template="fmat/ftprices/product/view/tierprices.phtml"/>
    </reference>
</catalog_product_view>

in catalog/product/view.phtml I get the block via:

echo $this->getChildHtml('custom_tierprices');

Once I change block type in module's layout file from type="fmat_ftprices/product_view_tierprices" to type="catalog/product_view" the template shows up in the front end. Can you see any errors in my files?

I'd appreciate your input.

3
  • can you please put config.xml .. All above code seems ok. Also please check module Fmat_FtPrices.xml exits or not at app/etc/modules/
    – Amit Bera
    Feb 27, 2015 at 12:02
  • Can you please show full code of config xml
    – Amit Bera
    Feb 27, 2015 at 13:42
  • @AmitBera I'm not on my development machine now. I'll update my question once I get to it.
    – Alan
    Feb 27, 2015 at 16:11

2 Answers 2

1

Personally I struggle to get any module to work when the module name has CamelCase in it. FtPrices probably resolves to ft/prices at some point. Therefore my suggestion is to go through your module files and replace FtPrices with Ftprices. After that the filenames/paths with 'FtPrices' will need to be 'Ftprices'.

By tidying up the CamelCase ambiguities I think your module will work as you want - seems you know your stuff and know what to post for a meaningful question.

2
  • Thanks Woolfie, I've experienced some camelCasing naming issues before but I'm working on a shop that's not entirely under my control so I was hoping that it can be solved without renaming the module. Nevertheless I'll give it a try and leave some feedback soon :).
    – Alan
    Feb 27, 2015 at 16:07
  • Unfortunately renaming the module didn't help. I'll need to do some more research. Thanks.
    – Alan
    Mar 5, 2015 at 10:31
1

The reason it didn't work for me was in module's config.xml:

<global>
 (...)
  <blocks>
   <fmat_ftprices>
    <class>Fmat_FtPrices_Block</class>
   </fmat_ftprices>
  </blocks>
</global>

I've removed _Product_View_Tierprices from block's class definition(leaving this fragment in the actual class name) and it worked.

I think that the naming here is confusing. On the one hand you're defining something inside the <class> tag, but on the other you're supposed to write a 'path' to Block classes, not the actual class name.


If someone still experiences this problem there is an interesting thread with similar issue but different solution(compiler): Magento new custom block module

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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