Monthly Archives: May 2014

Magento Conflicts

Magento have one of the biggest problem is cache and Extension Conflicts when more than one extension used the same
core File conflicts occurs and Developer had to struggle to find out the issues to fix it

Now if you see “<rewrite>” in it’s config.xml file in any of the extension it means Conflicts will occur.

But there are Extension which doesn’t conflict problems as by means of some standard Extensions are made
so that it should not conflict the other s module and the core functionality

May be there is chance that some time Theme also get conflict..as in Magento Community level as Developer
I have occur so many problem…

So now question comes how we can Resolve this Conflicts?

You have 3 Scenario for resolving conflicts:

Scenario 1
Merge the code from one conflicting file into another and
switch off the rewrite config.xml in one
Switch off the rewrite in one config.xml and then make the conflicting extension PHP file extend the other extension
Use the <depends> capability to make one extension depend on another. They will then rewrite in that order

Scenario 2
So we have example

class A_Extension_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
Now change it to:

class A_Extension_Model_Type_Onepage extends B_Extension_Model_Type_Onepage

Once you have done this you need to change extension B config.xml file

commenting out the conflicting “<rewrite>” blocks that are now inheriting from A.

Scenario 3
Let’s say you have 2 extensions Bla_A and Bla_B. In the module for file Bla_B (under app/etc/modules)
you would add the following:

<depends Foo_A />
Now Magento will load the extensions in this order. So in effect the Bla_B class will be loaded first,
then Bla_A, then base Magento

For Me scenario 2 Works perfect in order to avoid Conflict..Try it out ..hope this will help you

Magento Add new Column under sales item order

Recently I faced issues how to  add column to some table before it gets save in Magento.so here is the steps which will help to add the new column under sales_flat_order_item, sales_flat_invoice_item and sales_flat_shipment_item

so my field name is “vendor_name” in each of 3 tables and update the information without firing any query!
Step 1)
Create the installer script which will add the column in all 3 tables

<?php
$installer = $this;

$installer->startSetup();

$installer->run("
ALTER TABLE sales_flat_order_item ADD COLUMN vendor_name varchar(255) NULL;
ALTER TABLE sales_flat_invoice_item ADD COLUMN vendor_name varchar(255) NULL;
ALTER TABLE sales_flat_shipment_item ADD COLUMN vendor_name varchar(255) NULL;
");

$installer->endSetup();

?>

So once you run the script column will get added in your tables

STEP 2

so now we need to go for the event which will fire before order is placed, before invoice is created and before shipment is saved.add the events in config.xml

<sales_order_place_before>
<observers>
<adding_vendor_name_order>
<type>singleton</type>
<class>Namespace_Module_Model_Observer</class>
<method>saveVendorNameInOrder</method>
</adding_vendor_name_order>
</observers>
</sales_order_place_before>

<sales_order_invoice_save_before>
<observers>
<adding_vendor_name_invoice>
<type>singleton</type>
<class>Namespace_Module_Model_Observer</class>
<method>saveVendorNameInInvoice</method>
</adding_vendor_name_invoice>
</observers>
</sales_order_invoice_save_before>

<sales_order_shipment_save_before>
<observers>
<adding_vendor_name_shipment>
<type>singleton</type>
<class>Namespace_Module_Model_Observer</class>
<method>saveVendorNameInShipment</method>
</adding_vendor_name_shipment>
</observers>
</sales_order_shipment_save_before>

Step 3)

Now we need to create the observer.php

<?php
public function saveVendorNameInOrder(Varien_Event_Observer $observer) {
$order = $observer->getEvent()->getOrder();
/* add your bussiness Logic here */
return $this;
}

public function saveVendorNameInInvoice(Varien_Event_Observer $observer) {
$invoice = $observer->getEvent()->getInvoice();
/* add your bussiness Logic here */
return $this;
}

public function saveVendorNameInShipment(Varien_Event_Observer $observer)
{
$shipment = $observer->getEvent()->getShipment();
/* add your bussiness Logic here */
return $this;
}

?>

so once all done Clear the cache and the code will work as per need..hope this will help you