magento - Mage registry key "_singleton/" already exists error -
i know there lot of posts have seen , didn't find error in code bellow : config.xml :
<events> <core_block_abstract_to_html_after> <observers> <type>singleton</type> <class>webdirect_customprice_model_observer</class> <method>convertpricespantoinput</method> </observers> </core_block_abstract_to_html_after> </events>
observer class :
class webdirect_customprice_model_observer { const module_name = 'webdirect_customprice'; public function convertpricespantoinput($observer = null) { if (!$observer) { return; } if ('product.info.simple' == $observer->getevent()->getblock()->getnameinlayout()) { if (!mage::getstoreconfig('advanced/modules_disable_output/'.self::module_name)) { $transport = $observer->getevent()->gettransport(); $block = new webdirect_customprice_block_pricespantoinput(); $block->setpassingtransport($transport['html']); $block->tohtml(); } } return $this; } }
and class add custom javascript in product view page :
class webdirect_customprice_block_pricespantoinput extends mage_core_block_text { //protected $_nameinlayout = 'selectify.qty_input_to_select'; //protected $_alias = 'qty_input_to_select'; public function setpassingtransport($transport) { $this->setdata('text', $transport.$this->_generateqtyinputtoselecthtml()); } private function _generatepricespantoinputhtml() { $price = mage::registry('current_product')->getprice(); $product_id = mage::registry('current_product')->getid(); return ' <script type="text/javascript"> //<![cdata[ document.observe("dom:loaded", function() { $("product-price-'.$product_id.'").replace(\'<span class="price" id="product-price-'.$product_id.'"> <input type="text" id="cp_id" class="input-text price" name="custom_price" style="width:auto;" value="'.$price.'" onchange="onchangecp(this);"/></span><input type="hidden" id="custom_price_total" name="custom_price_total" value="'.$price.'">\'); }); //]]> </script> '; } }
is there error in code ? can't see anything!
the issue in defining observer function in config.xml.
<events> <core_block_abstract_to_html_after> <observers> <type>singleton</type> <class>webdirect_customprice_model_observer</class> <method>convertpricespantoinput</method> </observers> </core_block_abstract_to_html_after> </events>
should replaced by:
<events> <core_block_abstract_to_html_after> <observers> <some_unique_identifier> <type>singleton</type> <class>webdirect_customprice_model_observer</class> <method>convertpricespantoinput</method> </some_unique_identifier> </observers> </core_block_abstract_to_html_after> </events>
where "some_unique_identifier" can unique string.
Comments
Post a Comment