Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1106311
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T01:46:22+00:00 2026-05-17T01:46:22+00:00

** New EDIT ** so what I’m trying to do is this. I want

  • 0

** New EDIT **

so what I’m trying to do is this.

I want the to add new form elements generated by my module on the product view of the following url

http://magento.example.com/catalog/product/view/id/46

ultimately these elements will be determined to show up by a related table in my module

I expected that if I extended Mage_Catalog_Block_Product_View in my module as shown below I would be able to create a block in the product form that would contain such form fields, only if he are in the related table in my module

so I created a test.phtml file in

 app/design/frontend/default/default/templates/<module>/test.phtml

then as you can see in my the View.php file described bellow I built the block and displayed it in the product view.

It did appear but 5 times too many. from the answers below this is normal so that answers the question as to why the it shows up five times but leaves the question what is the proper way to proceecd since this plan is not going to work

** End New Edit **

in my module I call _prepareLayout() and it does this 5 times when i pull up the page

here’s my code
in

/app/code/local/Namespace/Module/Product/Veiw.php
class <Namespace>_<module>_Block_Product_View extends Mage_Catalog_Block_Product_View {
    protected function _toHtml() {
        return parent::_toHtml();
    }

    public function _prepareLayout() {
        $block = $this->getLayout()->createBlock(
            'Mage_Core_Block_Template',
            'my_block_name_here',
            array('template' => '<module>/test.phtml')
        );
        if ($block){
            $this->getLayout()->getBlock('content')->insert($block)->toHtml();
        }else{
            echo "no block";
        }
            return parent::_prepareLayout();
    }
}

NOTE:
I just noticed this also takes away the price availability qty and add to cart button. which is also a problem

EDIT
First I want to thank you all for your answers. Second i want to give you more context

the reason for choosing to do this in the module is that I don’t want the block to show up on every product . What i have is a table of what I’ll call custom options containing properties of the product sort of like hair color height weight etc and depending on what set of properties are attached to the product (if any) will depend on what html content will show up on the page.
so in one case it my get a drop down menu and in another case it may get an input box. the other very important piece is that this must be setup so that I can give the end result out as a module that can be installed and not worrry that it won’t show up if someone upgrades there magento

that said does it still make sense to do this all in the xml file ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T01:46:23+00:00Added an answer on May 17, 2026 at 1:46 am

    I took a look at a stock Magento install of CE 1.4.1, and unmodified the _prepareLayout method is called six times when loading the URL

    http://magento.example.com/catalog/product/view/id/46
    

    That’s because the class is instantiated six times. So that’s the correct behavior.

    As for the vanishing element, I can’y say for sure, but your override to _prepareLayout doesn’t appear to either

    1. Do the same things as Mage_Catalog_Block_Product_View::_prepareLayout

    2. Call parent::_prepareLayout();

    When you override a class in a Magento you’re replacing an existing class with your own. If you change a method, you’re responsible for that old code being run.

    It’s not clear what you’re trying to accomplish here. You should consider breaking your problem down into smaller problems, and then posting one (or more) “I tried X, expected Y, and got Z” type questions. As written no one’s going to be able to answer your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to add a new form to the edit customer page, so far
NEW EDIT: I have narrowed my problem to this - i have a view
Hi I'm trying to use a form as a partial for both the new/edit
Say I have two fields in a new or edit form: <%= f.text_field :email
EDIT : proper solution: void add(Student s) { if(root == null) root = new
I'm trying to edit a form, the route is controller/id/action for edit so for
EDIT: I added in where I create new instance of the class Process as
Whenever I try to edit existing or create new distribution provisioning profile on iOS
Why new()/delete() is slower than malloc()/free()? EDIT: Thanks for the answers so far. Please
new_story GET /story/new(.:format) {:action=>new, :controller=>stories} edit_story GET /story/edit(.:format) {:action=>edit, :controller=>stories} story GET /story(.:format) {:action=>show,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.