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

  • Home
  • SEARCH
  • 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

In Visual Studio 2008 add a new DataGridView to a form Edit Columns Add
Hi all I am trying to add ContexMenu into my Dynamically generated Tree. Below
And why don't they change it? Edit: The reason ask is because I'm new
New to javascript/jquery and having a hard time with using this or $(this) to
New to Linux programming in general. I am trying to communicate with a kernel
I am testing this controller: class SessionsController < ApplicationController def new end def create
New class is a subclass of the original object It needs to be php4
New to xml. Looking for XPath to search a xml file with python ElementTree
New to silverlight. Traditionally if I were to design a wizard-like process where a
New to both Ruby and Rails but I'm book educated by now (which apparently

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.