0

I am developing an custom extension following this guide: http://tutorialsformagento.blogspot.in/2014/06/add-custom-fields-to-order-and-quote.html

Here is my config file:

<?xml version="1.0"?>
<config>
    <modules>
        <VivasIndustries_Vshipping>
            <version>0.1.0</version>
        </VivasIndustries_Vshipping>
    </modules>
    <frontend>
        <routers>          
            <!-- <vshipping>
                 <use>standard</use>
                 <args>
                     <module>VivasIndustries_Vshipping</module>
                     <frontName>party</frontName>
                 </args>
             </vshipping>-->
        </routers>
        <layout>
            <updates>
                <vshipping>
                    <file>vshipping.xml</file>
                </vshipping>
            </updates>
        </layout>
    </frontend>
    <adminhtml>
        <layout>
            <updates>
                <vshipping>
                    <file>vivasindustries/vshipping.xml</file>
                </vshipping>
            </updates>
        </layout>
    </adminhtml>
    <global>
        <events>
            <checkout_type_onepage_save_order>
                <observers>
                    <checkout>
                        <type>singleton</type>
                        <class>VivasIndustries_Vshipping_Model_Observer</class>
                        <method>customDataSave</method>
                    </checkout>
                </observers>
            </checkout_type_onepage_save_order>
            <sales_quote_save_before> <!-- Name of Event -->
                <observers>
                    <save_before>
                        <type>singleton</type>
                        <class>VivasIndustries_Vshipping_Model_Observer</class>
                        <!-- Over Model Class -->
                        <method>saveQuoteBefore</method>
                        <!-- name of function -->
                    </save_before>
                </observers>
            </sales_quote_save_before>
        </events>
        <models>
            <sales>
                <rewrite>
                    <order>VivasIndustries_Vshipping_Model_Sales_Order</order>
                </rewrite>
            </sales>
            <vshipping>
                <class>VivasIndustries_Vshipping_Model</class>
                <resourceModel>vshipping_resource</resourceModel>
            </vshipping>
            <vshipping_resource>
                <class>VivasIndustries_Vshipping_Model_Resource</class>
            </vshipping_resource>
        </models>
        <resources>
            <vshipping_setup>
                <setup>
                    <module>VivasIndustries_Vshipping</module>
                </setup>
                <connection>
                    <use>core_setup</use>
                </connection>
            </vshipping_setup>
            <vshipping_read>
                <connection>
                    <use>core_read</use>
                </connection>
            </vshipping_read>
            <vshipping_write>
                <connection>
                    <use>core_write</use>
                </connection>
            </vshipping_write>
        </resources>
        <blocks>

            <vshipping>
                <class>VivasIndustries_Vshipping_Block</class>
            </vshipping>
        </blocks>
        <helpers>
            <vshipping>
                <class>VivasIndustries_Vshipping_Helper</class>
            </vshipping>
        </helpers>
    </global>
</config>

Here is my: /sql/vshipping_setup/mysql4-install-1.0.0.php:

<?php
/* @var $installer Mage_Core_Model_Resource_Setup */
require_once('app/Mage.php');
$installer = $this;
$installer->startSetup();
Mage::app()->setCurrentStore(Mage::getModel('core/store')->load(Mage_Core_Model_App::ADMIN_STORE_ID));
$installer = new Mage_Sales_Model_Resource_Setup('core_setup');
$attribute  = array(
    'type' => 'varchar',
    'backend_type' => 'varchar',
    'frontend_input' => 'varchar',
    'is_user_defined' => true,
    'label' => 'Delivery Date',
    'visible' => true,
    'required' => false,
    'user_defined' => false,
    'default' => '0',
    'comparable' => false,
    'searchable' => false,
    'filterable' => false
);
$installer->addAttribute('order','vshipping_account_no',$attribute);
$installer->addAttribute('quote','vshipping_account_no',$attribute);
$installer->addAttribute('order','vshipping_phone_no',$attribute);
$installer->addAttribute('quote','vshipping_phone_no',$attribute);
$installer->addAttribute('order','vshipping_comment',$attribute);
$installer->addAttribute('quote','vshipping_comment',$attribute);
$installer->endSetup();

However when i export my whole database with PHPMyAdmin and i search for vshipping_account_no there is no result found.

It seems this sql installer is not creating this mysql changes.

Where is my mistake and how can i fix it ?

Thanks in advance!

2

In a quick glance, your module version number in the config.xml and the setup version number in the setup install script file name doesn't match.

mysql4-install-1.0.0.php should be mysql4-install-0.1.0.php

And you can keep your setup file as simple as shown below. I can find too many unnecessary lines in your setup file.

$installer = $this;
$installer->startSetup();    
$installer->addAttribute("order", "vshipping_account_no", array("type"=>"varchar"));
$installer->addAttribute("quote", "vshipping_account_no", array("type"=>"varchar"));
$installer->addAttribute('order','vshipping_phone_no', array("type"=>"varchar"));
$installer->addAttribute('quote','vshipping_phone_no', array("type"=>"varchar"));
$installer->addAttribute('order','vshipping_comment', array("type"=>"varchar"));
$installer->addAttribute('quote','vshipping_comment', array("type"=>"varchar"));
$installer->endSetup();

Above all, this SO thread below should be a great help to get this done.

https://stackoverflow.com/questions/12936470/adding-a-new-attribute-to-order-in-magento

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.