Magento - MySQL - SQL 规则不适用于新扩展


Magento - MySQL - SQL rules are NOT working for new Extension

我正在为Magento 1.9.0.1开发一个新的扩展。

让我给你一些信息。

我已经完全禁用了缓存系统。

当我开发扩展时,我通过phpmyadmin创建了MySQL表。当我完成并打包它时,我尝试将其安装在另一个Magento上,然后我注意到MySQL表不是通过安装创建的。

请注意,我没有收到任何错误。

这是我的配置中的内容:

<?xml version="1.0"?>
<config>
  <modules>
    <VivasIndustries_SmsNotification>
      <version>1.0.0</version>
    </VivasIndustries_SmsNotification>
  </modules>
  <global>
    <models>
        <smsnotification>
            <class>VivasIndustries_SmsNotification_Model</class>
            <resourceModel>vivasindustries_smsnotification_resource</resourceModel>
        </smsnotification>
        <vivasindustries_smsnotification_resource>
        <class>VivasIndustries_SmsNotification_Model_Resource</class>
        <entities>
            <smsnotification>
            <table>VivasIndustries_SmsNotification</table>
            </smsnotification>
            <smsnotificationhistory>
            <table>VivasIndustries_SmsHistory</table>
            </smsnotificationhistory>
        </entities>
        </vivasindustries_smsnotification_resource>
    </models>
    <resources>
        <smsnotification_setup>
            <setup>
                <module>VivasIndustries_SmsNotification</module>
            </setup>
            <connection>
                 <use>core_setup</use>
             </connection>
        </smsnotification_setup>
        <smsnotification_read>
            <connection>
                <use>core_read</use>
            </connection>
        </smsnotification_read>
        <smsnotification_write>
            <connection>
                <use>core_write</use>
            </connection>
        </smsnotification_write>
    </resources>    
    <events>
    <checkout_type_onepage_save_order_after> <!-- identifier of the event we want to catch -->
        <observers>
          <checkout_type_onepage_save_order_after_smsprice_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>smsnotification/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveSmspriceTotal</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </checkout_type_onepage_save_order_after_smsprice_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_smsprice_handler> <!-- identifier of the event handler -->
            <type>model</type> <!-- class method call type; valid are model, object and singleton -->
            <class>smsnotification/newordertotalobserver</class> <!-- observers class alias -->
            <method>saveSmspriceTotalForMultishipping</method>  <!-- observer's method to be called -->
            <args></args> <!-- additional arguments passed to observer -->
          </checkout_type_multishipping_create_orders_single_smsprice_handler>      
        </observers>
      </checkout_type_multishipping_create_orders_single>     
        <sales_order_save_after>
            <observers>
                <vivasindustries_smsnotification>
                    <class>smsnotification/observer</class>
                    <method>orderSaved</method>
                </vivasindustries_smsnotification>
            </observers>
        </sales_order_save_after>
    </events>
     <sales>
        <quote>
            <totals>                
                <smsprice_total>
                    <class>smsnotification/quote_address_total_smsprice</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </smsprice_total> 
            </totals>
        </quote>
            <order_invoice>
                <totals>                
                <smsprice_total>
                    <class>smsnotification/order_invoice_total_smsprice</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </smsprice_total> 
                </totals>
            </order_invoice>
            <order_creditmemo>
                <totals>                
                <smsprice_total>
                    <class>percentpayment/order_creditmemo_total_smsprice</class>
                    <after>subtotal,freeshipping,tax_subtotal,shipping</after>
                    <before>grand_total</before>
                </smsprice_total> 
                </totals>
            </order_creditmemo>
    </sales>    
    <helpers>
        <smsnotification>
            <class>VivasIndustries_SmsNotification_Helper</class>
        </smsnotification>
    </helpers>
    <blocks>
        <smsnotification>
             <class>VivasIndustries_SmsNotification_Block</class>
        </smsnotification>
    </blocks>
  </global>
  <adminhtml>
    <acl>
        <resources>
            <all>
                <title>Allow Everything</title>
            </all>
            <admin>
                <children>
                    <system>
                        <children>
                            <config>
                                <children>
                                    <vivas>
                                        <title>Vivas - All</title>
                                    </vivas>
                                </children>
                            </config>
                        </children>
                    </system>
                </children>
            </admin>
        </resources>
    </acl>
    <layout>
        <updates>
            <smsnotification>
                <file>smsnotification.xml</file>
            </smsnotification>
        </updates>
    </layout>   
    </adminhtml>
    <admin>
        <routers>
            <adminhtml>
                <args>
                    <modules>
                        <VivasIndustries_SmsNotification before="Mage_Adminhtml">VivasIndustries_SmsNotification_Adminhtml</VivasIndustries_SmsNotification>
                    </modules>
                </args>
            </adminhtml>
        </routers>
    </admin>
    <default>
    <vivas>
        <smspricegroup>                
            <smsprice_name>SMS Notification</smsprice_name>
            <smsprice_fee>0.5</smsprice_fee>            
        </smspricegroup>      
    </vivas>
    </default>
</config>

这是我在: /app/code/community/VivasIndustries/SmsNotification/sql/smsnotification_setup/install-1.0.0.php

<?php
$installer=$this;
$installer->startSetup();
$installer->addAttribute("quote_address", "smsprice_total", array("type"=>"varchar"));
$installer->addAttribute("order", "smsprice_total", array("type"=>"varchar"));
$installer->run("
CREATE TABLE IF NOT EXISTS `VivasIndustries_SmsNotification` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `state` varchar(500) NOT NULL,
  `smstext` varchar(500) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `VivasIndustries_SmsHistory` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `receiver` varchar(500) NOT NULL,
  `phone` varchar(500) NOT NULL,
  `email` varchar(500) NOT NULL,
  `smstext` text NOT NULL,
  `date` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;
    ");
$installer->endSetup();
?>

即使不运行两个 addAttributes ,它也不会创建表

那么伙计们为什么这个扩展不创建 MySQL 表,我该如何解决它?

谢谢!

首先:在你的安装文件中放一个骰子,看看它是否到达那里。若要进一步调试,请查看是否在 core_resource 中为smsnotification_setup创建/已创建任何条目,如果是,请删除它们以重新运行安装程序。

次要的,

出于对简单的热爱,不要将模块名称大小写,以避免太多的痛苦和痛苦。

这是一个非驼峰外壳的安装程序原型:

配置.xml:

<?xml version="1.0"?>
<config>
    <modules>
        <Vivasindustries_Smsnotification>
            <version>1.0.0</version>
        </Vivasindustries_Smsnotification>
    </modules>
    <global>
        <resources>
            <smsnotification_setup>
                <setup>
                    <module>Vivasindustries_Smsnotification</module>
                    <class>Vivasindustries_Smsnotification_Model_Resource_Setup</class>
                </setup>
            </smsnotification_setup>
        </resources>
    </global>
</config>

安装人员: sql/smsnotification_setup/mysql4-install-1.0.0.php

// die( 'In install!' );
$installer = $this;
$installer->startSetup();
$installer->run("
    CREATE TABLE IF NOT EXISTS...
    ");
$installer->endSetup();