php - Magento - Blank page when creating new module -
php - Magento - Blank page when creating new module -
i'm using mangeto 1.9.1 , i'm trying create module 50% discount grandtotal price.
i've made things module when seek open http://mymagento.com/checkout/cart/ i've got blank page bellow main menu. blank page cart items , total should be.
take look:
i've made module answer: magento - issue creating custom module
so here i've done:
in app/code/local/vivasindustries/percentpayment/etc/config.xml :
<?xml version="1.0"?> <config> <modules> <vivasindustries_percentpayment> <version>0.1.0</version> </vivasindustries_percentpayment> </modules> <global> <models> <percentpayment> <class>vivasindustries_percentpayment_model</class> <resourcemodel>percentpayment_mysql4</resourcemodel> </percentpayment> </models> <resources> <percentpaymentatribute_setup> <setup> <module>vivasindustries_percentpayment</module> <class>mage_sales_model_mysql4_setup</class> </setup> <connection> <use>core_setup</use> </connection> </percentpaymentatribute_setup> <percentpaymentatribute_write> <connection> <use>core_write</use> </connection> </percentpaymentatribute_write> <percentpaymentatribute_read> <connection> <use>core_read</use> </connection> </percentpaymentatribute_read> </resources> <events> <checkout_type_onepage_save_order_after> <!-- identifier of event want grab --> <observers> <checkout_type_onepage_save_order_after_discount_handler> <!-- identifier of event handler --> <type>model</type> <!-- class method phone call type; valid model, object , singleton --> <class>percentpayment/newordertotalobserver</class> <!-- observers class alias --> <method>savediscounttotal</method> <!-- observer's method called --> <args></args> <!-- additional arguments passed observer --> </checkout_type_onepage_save_order_after_discount_handler> </observers> </checkout_type_onepage_save_order_after> <checkout_type_multishipping_create_orders_single> <!-- identifier of event want grab --> <observers> <checkout_type_multishipping_create_orders_single_discount_handler> <!-- identifier of event handler --> <type>model</type> <!-- class method phone call type; valid model, object , singleton --> <class>percentpayment/newordertotalobserver</class> <!-- observers class alias --> <method>savediscounttotalformultishipping</method> <!-- observer's method called --> <args></args> <!-- additional arguments passed observer --> </checkout_type_multishipping_create_orders_single_discount_handler> </observers> </checkout_type_multishipping_create_orders_single> </events> <sales> <quote> <totals> <discount_total> <class>percentpayment/quote_address_total_discount</class> <after>subtotal,freeshipping,tax_subtotal,shipping</after> <before>grand_total</before> </discount_total> </totals> </quote> <order_invoice> <totals> <discount_total> <class>percentpayment/order_invoice_total_discount</class> <after>subtotal,freeshipping,tax_subtotal,shipping</after> <before>grand_total</before> </discount_total> </totals> </order_invoice> <order_creditmemo> <totals> <discount_total> <class>percentpayment/order_creditmemo_total_discount</class> <after>subtotal,freeshipping,tax_subtotal,shipping</after> <before>grand_total</before> </discount_total> </totals> </order_creditmemo> </sales> </global> </config>
in in app/code/local/vivasindustries/percentpayment/model/newordertotalobserver.php:
<?php class vivasindustries_percentpayment_model_newordertotalobserver { public function savediscounttotal(varien_event_observer $observer) { $order = $observer -> getevent() -> getorder(); $quote = $observer -> getevent() -> getquote(); $shippingaddress = $quote -> getshippingaddress(); if($shippingaddress && $shippingaddress -> getdata('discount_total')){ $order -> setdata('discount_total', $shippingaddress -> getdata('discount_total')); } else{ $billingaddress = $quote -> getbillingaddress(); $order -> setdata('discount_total', $billingaddress -> getdata('discount_total')); } $order -> save(); } public function savediscounttotalformultishipping(varien_event_observer $observer) { $order = $observer -> getevent() -> getorder(); $address = $observer -> getevent() -> getaddress(); $order -> setdata('discount_total', $shippingaddress -> getdata('discount_total')); $order -> save(); } }
in app/code/local/vivasindustries/percentpayment/model/order/creditmemo/total/discount.php: homecoming $this; $order = $creditmemo->getorder(); $orderdiscounttotal = $order->getdiscounttotal(); if ($orderdiscounttotal) { $creditmemo->setgrandtotal($creditmemo->getgrandtotal()+$orderdiscounttotal); $creditmemo->setbasegrandtotal($creditmemo->getbasegrandtotal()+$orderdiscounttotal); } homecoming $this; } }
in app/code/local/vivasindustries/percentpayment/model/order/invoice/total/discount.php:
<?php class vivasindustries_percentpayment_model_order_invoice_total_discount extends mage_sales_model_order_invoice_total_abstract { public function collect(mage_sales_model_order_invoice $invoice) { $order=$invoice->getorder(); $orderdiscounttotal = $order->getdiscounttotal(); if ($orderdiscounttotal&&count($order->getinvoicecollection())==0) { $invoice->setgrandtotal($invoice->getgrandtotal()+$orderdiscounttotal); $invoice->setbasegrandtotal($invoice->getbasegrandtotal()+$orderdiscounttotal); } homecoming $this; } }
in app/code/local/vivasindustries/percentpayment/model/quote/address/total/discount.php:
<?php class vivasindustries_percentpayment_model_quote_address_total_discount extends mage_sales_model_quote_address_total_abstract { public function __construct() { $this -> setcode('discount_total'); } /** * collect totals info discount * * @param mage_sales_model_quote_address $address * @return mage_sales_model_quote_address_total_shipping */ public function collect(mage_sales_model_quote_address $address) { parent :: collect($address); $items = $this->_getaddressitems($address); if (!count($items)) { homecoming $this; } $quote= $address->getquote(); //amount definition $discountamount = 50; //amount definition $discountamount = $quote -> getstore() -> roundprice($discountamount); $this -> _setamount($discountamount) -> _setbaseamount($discountamount); $address->setdata('discount_total',$discountamount); homecoming $this; } /** * add together discount totals info address object * * @param mage_sales_model_quote_address $address * @return mage_sales_model_quote_address_total_shipping */ public function fetch(mage_sales_model_quote_address $address) { parent :: fetch($address); $amount = $address -> gettotalamount($this -> getcode()); if ($amount != 0){ $address -> addtotal(array( 'code' => $this -> getcode(), 'title' => $this -> getlabel(), 'value' => $amount )); } homecoming $this; } /** * label * * @return string */ public function getlabel() { homecoming mage :: helper('modulename') -> __('discount'); } }
and in app/code/local/vivasindustries/percentpayment/sql/percentpaymentatribute_setup/mysql4-install-0.1.0.php:
<?php $installer = $this; $installer->startsetup(); $installer->addattribute("quote_address", "discount_total", array("type"=>"varchar")); $installer->addattribute("order", "discount_total", array("type"=>"varchar")); $installer->endsetup();
and finaly i've made this:
in app/etc/modules/vivasindustries_percentpayment.xml:
<?xml version="1.0"?> <config> <modules> <vivasindustries_percentpayment> <active>true</active> <codepool>local</codepool> <version>0.1.0</version> </vivasindustries_percentpayment> </modules> </config>
and that's i've done , blank page no error.
can please help me find problem , prepare it?
*edit
when remove:
public function getlabel() { homecoming mage :: helper('modulename') -> __('discount'); }
the page fixed , showing discount value without "discount" description.
thanks in advance!
change magento developer mode open log track issue log
php magento
Comments
Post a Comment