Magento Forum

Page 1 of 2
Problem Overloading Method getSelectionTitlePrice() in Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option? 
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

Hi,

I do not get this done for hours now. Does anybody see the error?

My config.xml:

<?xml version="1.0"?>
<config>
    <
modules>
        <
Pulpmedia_NoPlusZero>
            <
version>0.1.0</version>
        </
Pulpmedia_NoPlusZero>
    </
modules>
    <global>
        <
blocks>           
            <
nopluszero>
                <
rewrite>
                    <
catalog_product_view_type_bundle_option>Pulpmedia_NoPlusZero_Block_Catalog_Product_View_Type_Bundle_Option</catalog_product_view_type_bundle_option>
                </
rewrite>
            </
nopluszero>   
        </
blocks>
    </global>     
</
config>

Option.php (I even try to produce an error, but I see nothing)

<?php
class Pulpmedia_NoPlusZero_Block_Catalog_Product_View_Type_Bundle_Option extends Mage_Bundle_Block_Catalog_Product_View_Type_Bundle_Option
{
    
public function getSelectionTitlePrice($_selection$includeContainer true)
    
{
        $price 
$this->getProduct()->getPriceModel()->getSelectionPreFinalPrice($this->getProduct(), $_selection1);
        
$html $_selection->getName();
        
        echo 
'x;
        
        return $html;
    }
}

Pulpmedia_NoPlusZero.xml

<config>
    <
modules>
        <
Pulpmedia_NoPlusZero>
            <
active>true</active>
            <
codePool>local</codePool>
            <
version>0.1.0</version>
        </
Pulpmedia_NoPlusZero>
    </
modules>
</
config>

Does anybody see bad code here?

Image Attachments
structure.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

check your config.xml code…

<global>
        <
blocks>           
            <
catalog>
                <
rewrite>
                    <
product_view_type_bundle_option>Pulpmedia_NoPlusZero_Block_Catalog_Product_View_Type_Bundle_Option</catalog_product_view_type_bundle_option>
                </
rewrite>
            </
catalog>   
        </
blocks>
    </global>

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

thanks, but no change. i don’t get errors or anything else.

 
Magento Community Magento Community
Magento Community
Magento Community
 
ylibrach
Sr. Member
 
Total Posts:  78
Joined:  2008-07-06
 

Zentrate had another small error in the code he pasted for you. Try this:

<global>
        <
blocks>           
            <
catalog>
                <
rewrite><product_view_type_bundle_option>Pulpmedia_NoPlusZero_Block_Catalog_Product_View_Type_Bundle_Option</product_view_type_bundle_option>
                </
rewrite>
            </
catalog>   
        </
blocks>
    </global>
 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

if you didnt get an error on my solution within config.xml your module wasnt loaded. Coz i had an missmatching error of nodes in the xml-file. if your module would be loaded there should be a simple_xml parsing error shown.

cheers

Stefan

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

I think I did not take your whole code, so I did not see that your XML file was a bad one. I attached a zip file here, where all files are included. And I am 80% sure, that there are no mistakes here.

I tried to add some stupid characters to my XML file and I got an XML error, so I think my module is loaded.

Does anybody know how to debug this?

File Attachments
app.zip  (File Size: 7KB - Downloads: 107)
 
Magento Community Magento Community
Magento Community
Magento Community
 
mzentrale1
Guru
 
Total Posts:  731
Joined:  2007-12-06
Stuttgart, Germany
 

Hi,

is your module show in backend: system->configuration->advanced?
You should test this first, if not, your Pulpmedia_Bundle.xml isnt valid.

cheers

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

shows up there and is “enabled”

Image Attachments
nopluszero.png
 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

reward: $30 for a solution to this wink

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 

tried this without success…

<?xml version="1.0"?>
<config>
    <
modules>
        <
Pulpmedia_NoPlusZero>
            <
version>0.1.0</version>
        </
Pulpmedia_NoPlusZero>
    </
modules>
    <global>
        <
models>
            <
nopluszero>
                <class>
Pulpmedia_NoPlusZero_Model</class>               
            </
nopluszero>
        </
models>
        <
blocks>           
            <
catalog>
                <
rewrite>
                  <
product_view_type_bundle_option>Pulpmedia_NoPlusZero_Catalog_Product_View_Type_Bundle_Option</product_view_type_bundle_option>
                </
rewrite>
            </
catalog>   
        </
blocks>
    </global>     
</
config>

... and this too…

<?xml version="1.0"?>
<config>
    <
modules>
        <
Pulpmedia_NoPlusZero>
            <
version>0.1.0</version>
        </
Pulpmedia_NoPlusZero>
    </
modules>
    <global>
        <
models>
            <
nopluszero>
                <class>
Pulpmedia_NoPlusZero_Model</class>               
            </
nopluszero>
        </
models>
        <
blocks>           
            <
bundle>
                <
rewrite>
                    <
catalog_product_view_type_bundle_option>Pulpmedia_NoPlusZero_Block_Catalog_Product_View_Type_Bundle_Option</catalog_product_view_type_bundle_option>
                </
rewrite>
            </
bundle>   
        </
blocks>
    </global>     
</
config>

any other suggestions?

I tried to overload a simple Model, this worked out fine…

<?xml version="1.0"?>   
<config>
    <
modules>
        <
Pulpmedia_NoImageFrame>
            <
version>0.1.0</version>
        </
Pulpmedia_NoImageFrame>
    </
modules>
    <global>       
        <
models>
            <
noimageframe>
                <class>
Pulpmedia_NoImageFrame_Model</class>               
            </
noimageframe>
            <
catalog>
                <
rewrite>
                    <
product_image>Pulpmedia_NoImageFrame_Model_Product_Image</product_image>
                </
rewrite>
            </
catalog>
        </
models>       
    </global> 
</
config>
 
Magento Community Magento Community
Magento Community
Magento Community
 
ylibrach
Sr. Member
 
Total Posts:  78
Joined:  2008-07-06
 

This issue may be related to threads here and here that deal with overriding blocks and models which are more than one level deep.

It’s strange because I have no problem overriding some files which are more than one level deep while others don’t work.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michae1
Enthusiast
 
Total Posts:  826
Joined:  2007-08-31
 

catalog_product_view_type_bundle_option block is never instantiated itself.

If you are developing Magento extension you have to rewrite it’s descendants:

<bundle>
    <
rewrite>
        <
catalog_product_view_type_bundle_option_select>MyModule_Block_Bundle_Option_Select</catalog_product_view_type_bundle_option_select>
        <
catalog_product_view_type_bundle_option_multi>MyModule_Block_Bundle_Option_Multi</catalog_product_view_type_bundle_option_multi>
        <
catalog_product_view_type_bundle_option_radio>MyModule_Block_Bundle_Option_Radio</catalog_product_view_type_bundle_option_radio>
        <
catalog_product_view_type_bundle_option_checkbox>MyModule_Block_Bundle_Option_Checkbox</catalog_product_view_type_bundle_option_checkbox>
    </
rewrite>
</
bundle>

If you not developing an extension, and you are trying to customize just your store, you can make it simpler - from bundle.xml layout :

<block type="bundle/catalog_product_view_type_bundle" name="product.info.bundle.options" as="type_bundle_options" template="bundle/catalog/product/view/type/bundle/options.phtml">
                <
action method="addRenderer"><type>select</type><block>mymodule/catalog_product_view_type_bundle_option_select</block></action>
                <
action method="addRenderer"><type>multi</type><block>mymodule/catalog_product_view_type_bundle_option_multi</block></action>
                <
action method="addRenderer"><type>radio</type><block>mymodule/catalog_product_view_type_bundle_option_radio</block></action>
                <
action method="addRenderer"><type>checkbox</type><block>mymodule/catalog_product_view_type_bundle_option_checkbox</block></action>
            </
block>

You can set any renderers for different option types here directly.

 
Magento Community Magento Community
Magento Community
Magento Community
 
scree
Sr. Member
 
Avatar
Total Posts:  137
Joined:  2008-07-14
Linz
 
Michael - 09 October 2008 04:28 AM

catalog_product_view_type_bundle_option block is never instantiated itself.

So how do I know this?

 
Magento Community Magento Community
Magento Community
Magento Community
 
Michae1
Enthusiast
 
Total Posts:  826
Joined:  2007-08-31
 
scree - 09 October 2008 05:01 AM

Michael - 09 October 2008 04:28 AM
catalog_product_view_type_bundle_option block is never instantiated itself.

So how do I know this?

This block is not used in any layout, it’s just an ancestor of catalog_product_view_type_bundle_option_… blocks (and these ones are used).

If you are interested in how do rewrites work in general, you can check Mage_Core_Model_Config->getGroupedClassName() method.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Geraint
Jr. Member
 
Total Posts:  5
Joined:  2007-09-15
 

Thanks to Michael’s explanation about rewriting the descendent classes I got this to work. 

What is more interesting is that scree wanted to do the same thing as me which is to suppress the +0.00 price for bundle radio boxes.

Perhaps for bundle sub-products with a zero price this should be the default ??

Geraint

 
Magento Community Magento Community
Magento Community
Magento Community
 
Rational Calvert
Jr. Member
 
Total Posts:  17
Joined:  2008-06-03
 

I think it should definitely be the default.

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top
Page 1 of 2