1

I'm looking to remove old quotes from the database via a Magento shell script, and I see enterprise_customer_sales_flat_quote and enterprise_customer_sales_flat_quote_address whose purpose is unclear to me. These are don't have any key constraint on them to the native Mage tables.

In the Enterprise_Customer module, under which the models for these tables are, there is not much responsible code. What are these for, and are they safe to remove along with the "associated" sales_flat_quote/_address records? ("associated" because there is no formal constraint but they seem to have the same entity_ids.

1

These tables are mainly used when events are called, and there are a lot of them, all found in app/code/core/Enterprise/Customer/etc/config.xml:

<sales_quote_load_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesQuoteAfterLoad</method>
        </enterprise_customer>
    </observers>
</sales_quote_load_after>
<sales_quote_address_collection_load_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesQuoteAddressCollectionAfterLoad</method>
        </enterprise_customer>
    </observers>
</sales_quote_address_collection_load_after>
<sales_quote_save_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesQuoteAfterSave</method>
        </enterprise_customer>
    </observers>
</sales_quote_save_after>
<sales_quote_address_save_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesQuoteAddressAfterSave</method>
        </enterprise_customer>
    </observers>
</sales_quote_address_save_after>
<sales_order_load_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesOrderAfterLoad</method>
        </enterprise_customer>
    </observers>
</sales_order_load_after>
<sales_order_address_collection_load_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesOrderAddressCollectionAfterLoad</method>
        </enterprise_customer>
    </observers>
</sales_order_address_collection_load_after>
<sales_order_save_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesOrderAfterSave</method>
        </enterprise_customer>
    </observers>
</sales_order_save_after>
<sales_order_address_save_after>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>salesOrderAddressAfterSave</method>
        </enterprise_customer>
    </observers>
</sales_order_address_save_after>
<enterprise_customer_attribute_before_save>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>enterpriseCustomerAttributeBeforeSave</method>
        </enterprise_customer>
    </observers>
</enterprise_customer_attribute_before_save>
<enterprise_customer_attribute_save>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>enterpriseCustomerAttributeSave</method>
        </enterprise_customer>
    </observers>
</enterprise_customer_attribute_save>
<enterprise_customer_attribute_delete>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>enterpriseCustomerAttributeDelete</method>
        </enterprise_customer>
    </observers>
</enterprise_customer_attribute_delete>
<enterprise_customer_address_attribute_save>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>enterpriseCustomerAddressAttributeSave</method>
        </enterprise_customer>
    </observers>
</enterprise_customer_address_attribute_save>
<enterprise_customer_address_attribute_delete>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>enterpriseCustomerAddressAttributeDelete</method>
        </enterprise_customer>
    </observers>
</enterprise_customer_address_attribute_delete>
<core_copy_fieldset_sales_convert_quote_to_order>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetSalesConvertQuoteToOrder</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_convert_quote_to_order>
<core_copy_fieldset_sales_convert_quote_address_to_order_address>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetSalesConvertQuoteAddressToOrderAddress</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_convert_quote_address_to_order_address>
<core_copy_fieldset_sales_copy_order_to_edit>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetSalesCopyOrderToEdit</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_copy_order_to_edit>
<core_copy_fieldset_sales_copy_order_billing_address_to_order>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetSalesCopyOrderBillingAddressToOrder</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_copy_order_billing_address_to_order>
<core_copy_fieldset_sales_copy_order_shipping_address_to_order>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetSalesCopyOrderShippingAddressToOrder</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_copy_order_shipping_address_to_order>
<core_copy_fieldset_customer_account_to_quote>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetCustomerAccountToQuote</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_customer_account_to_quote>
<core_copy_fieldset_customer_address_to_quote_address>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetCustomerAddressToQuoteAddress</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_customer_address_to_quote_address>
<core_copy_fieldset_checkout_onepage_quote_to_customer>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetCheckoutOnepageQuoteToCustomer</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_checkout_onepage_quote_to_customer>
<core_copy_fieldset_sales_convert_quote_address_to_customer_address>
    <observers>
        <enterprise_customer>
            <class>enterprise_customer/observer</class>
            <method>coreCopyFieldsetQuoteAddressToCustomerAddress</method>
        </enterprise_customer>
    </observers>
</core_copy_fieldset_sales_convert_quote_address_to_customer_address>

It appears that what magento have done here is to latch onto the events rather than rewrite the community classes, which I think it a good solution from them.

If you look closely into one of these observers, we will take salesQuoteAfterLoad, it takes the quote from the observer and loads the enterprise version of it. It then calls attachAttributeData which simply adds all the data from the original quote into that enterprise quote.

public function salesQuoteAfterLoad(Varien_Event_Observer $observer)
{
    $quote = $observer->getEvent()->getQuote();
    if ($quote instanceof Mage_Core_Model_Abstract) {
        Mage::getModel('enterprise_customer/sales_quote')
            ->load($quote->getId())
            ->attachAttributeData($quote);
    }

    return $this;
}

I would suggest looking at this observer you are fairly safe. If you are clearing the community tables then you can also clear the enterprise tables. But obviously backup your data first :)

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.