Magento-创建新模块时的空白页 [英] Magento - Blank page when creating new module

查看:68
本文介绍了Magento-创建新模块时的空白页的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Mangeto 1.9.1,并且试图创建一个模块,以使价格从总价中获得50%的折扣.

I'm using Mangeto 1.9.1 and I'm trying to create a module for 50% discount from the grandtotal price.

我已经对该模块做了一些操作,但是当我尝试打开 http://mymagento时. com/checkout/cart/我的主菜单下有空白页.我的购物车项目和总计应在的空白页.

I've made some things to the module but when I try to open my http://mymagento.com/checkout/cart/ I've got blank page bellow my main menu. Blank page where my cart items and total should be.

看看:

我通过以下答案制作了此模块: Magento -创建自定义模块的问题

I've made this module by this answer: Magento - Issue with creating a custom Module

这就是我所做的:

在app/code/local/VivasIndustries/PercentPayment/etc/config.xml中:

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 the event we want to catch -->
        <observers>
          <checkout_type_onepage_save_order_after_discount_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveDiscountTotal</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </checkout_type_onepage_save_order_after_discount_handler>
        </observers>
      </checkout_type_onepage_save_order_after>     
    <checkout_type_multishipping_create_orders_single> <!-- identifier of the event we want to catch -->
        <observers>     
          <checkout_type_multishipping_create_orders_single_discount_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>percentpayment/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveDiscountTotalForMultishipping</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to 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>  

在应用程序/代码/本地/VivasIndustries/PercentPayment/模型/Newordertotalobserver.php中:

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();
     }
}

在app/code/local/VivasIndustries/PercentPayment/Model/Order/Creditmemo/Total/Discount.php中:

In app/code/local/VivasIndustries/PercentPayment/Model/Order/Creditmemo/Total/Discount.php:

        return $this;

        $order = $creditmemo->getOrder();
        $orderDiscountTotal        = $order->getDiscountTotal();

        if ($orderDiscountTotal) {
            $creditmemo->setGrandTotal($creditmemo->getGrandTotal()+$orderDiscountTotal);
            $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal()+$orderDiscountTotal);
        }

        return $this;
    }
}

在app/code/local/VivasIndustries/PercentPayment/Model/Order/Invoice/Total/Discount.php中:

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);
            }
            return $this;
        }
    }

在应用程序/代码/本地/VivasIndustries/PercentPayment/模型/报价/地址/总计/Discount.php中:

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 information about 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)) {
            return $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);

         return $this;
     }

    /**
     * Add discount totals information to 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
                    ));
         }

         return $this;
     }

    /**
     * Get label
     * 
     * @return string 
     */
     public function getLabel()
    {
         return Mage :: helper('modulename') -> __('Discount');
    }
}

在app/code/local/VivasIndustries/PercentPayment/sql/percentpaymentatribute_setup/mysql4-install-0.1.0.php中:

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();

最后我做了这个:

在app/etc/modules/VivasIndustries_PercentPayment.xml中:

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 all what I've done and I get this blank page with no error.

能帮我找到问题并解决吗?

Can you please help me find the problem and fix it?

*编辑

我什么时候删除:

 public function getLabel()
{
     return Mage :: helper('modulename') -> __('Discount');
}

该页面是固定的,仅显示折扣值,而没有折扣"说明.

The page is fixed and it is showing only the discount Value without the "Discount" description.

提前谢谢!

推荐答案

  1. 将您的magento更改为开发人员模式
  2. 操作日志
  3. 使用日志跟踪问题

这篇关于Magento-创建新模块时的空白页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆