13

i know there is a lot of posts that i have seen and i didn't find the error in the 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 a class that add a 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.'">&nbsp;<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 any error in that code ? I can't see anything!

2
  • Did you clear caches after installation? I had same problem today, but for me clearing cache worked. Commented May 12, 2016 at 18:41
  • clearing cache is one of a lot of solutions, solution for me described in the marked answer :) Commented May 15, 2016 at 18:21

2 Answers 2

23

The issue is in defining observer function in your 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 be 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 be any unique string.

Sign up to request clarification or add additional context in comments.

1 Comment

In my case I also had to change "<class>COMPANY_MODULE/observer</class>" to "<class>COMPANY_MODULE_Model_Observer</class>". Using Magento 1.9
-3

Comment out the two define function calls in includes/config.php path:

#define('COMPILER_INCLUDE_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'src'); #define('COMPILER_COLLECT_PATH', dirname(__FILE__).DIRECTORY_SEPARATOR.'stat'); 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.