6

Short version:

In our Magento database we have 40 records in our customer_entity table that have an entity_type_id that maps to an entity_type_code of 'customer_payment' in the eav_entity_type table. They are stopping us from converting to global account sharing between our stores. What are they for and can they safely be deleted?

Long version:

We are preparing to launch our second store on Magento Enterprise Edition v1.12.0.2 and we have recently decided to turn on global customer account sharing before launching the new storefront. All that should be required for this is to ensure that there are no email address collisions between the two stores' accounts, so I deleted test accounts for the new storefront expecting that we would be set but that is not the case.
Upon inspection of the records in the customer_entity table I found 40 records as described in the "short version" above. They are all created in quick succession of one another- just a handful of seconds to create them all- which leads me to believe that they must be auto-generated. Most fields are null or set to zero, including store_id, website_id, and email.
I searched every table that had a foreign key reference to the entity_id field of the customer_entity table for occurrences of the offending ids but they do not appear to be related to any other records in any other tables, at least not to those that enforce a foreign key relationship. It appears that even if they were related by foreign key relationships the database schema would gracefully cascade deletes and set values to null as needed.
A Google search for Magento & customer_payment yields very few results and none of any real use. All I've been able to determine is that 'customer_payment' appears to be a default entity type for Magento. I even went as far as to do a fresh install to see if the customer records might be auto generated at install time, but that is not the case.
So why are these present? What purpose do they serve, what generated them, and most importantly can I safely delete them?

migrated from stackoverflow.com Mar 5 '13 at 13:38

This question came from our site for professional and enthusiast programmers.

  • Could not find any reference to customer_payment in the code, nor could I find any such entries in one of our projects. Which version of Magento was running at the time these records have been created? – Alex Mar 4 '13 at 21:03
  • @Alex I believe we started out on 1.12.0.0. – joelmdev Mar 5 '13 at 15:25
3

Please note my answers below are referencing Magento CE, but I believe they still apply to Enterprise Edition too.

  • What generated them? Most likely the sample data SQL (http://www.magentocommerce.com/download). Did you use the sample data?
  • What purpose do they serve? In current versions of Magento, none.
  • Why are these present? You'll never believe this, but they are left over from the beta versions of Magento. They're not even used in Magento v1.0. I found the last reference to them in v0.7. Even the model classes referenced in the eav_entity_type table don't exist anymore. Mage_Customer_Model_Entity_Payment is an example of a class that hasn't existed since v0.7
  • Can I safely delete them? Yes! Unfortunately I can't give you a magic script to run. I fixed the situation by taking a backup of the database, deleting it and running the installer again to generate fresh tables. I then copied the core_config_data table and cms_* tables back. It was a very simple site though, you may need to take more care in what you copy if your installation is more complex.

I think it's safe to say that we've both learned the hard way that the Magento sample data shouldn't be used with production sites!

  • That is a very real possibility! Our production instance started out as a development instance that our development partner spun up. I will contact them to see if they used sample data on the install. Regarding deletion, a simple DELETE FROM customer_entity WHERE entity_id [id or range condition(s)] should take care of it. The Magento database schema is setup to cascade deletes as necessary. Alternatively you should be able to delete them through Magento API with $customer = Mage::getModel('customer/customer'); $customer->load($id); $customer->delete(); – joelmdev Mar 6 '13 at 17:08
  • Also, what version did you use sample data on where you experienced this? – joelmdev Mar 6 '13 at 17:09
  • You'd want to delete the actual EAV entity types as well from eav_entity_type. It would be worth comparing this table against a fresh install of Magento and deleting the extra entities. I believe deleting entity types will cascade delete from the eav_attribute table too. – jharrison.au Mar 6 '13 at 22:09
  • The extra entities are present in every version of the sample data up to v1.6.1.0 which is the version I used. – jharrison.au Mar 6 '13 at 22:10
  • You nailed it. From Magento Support: "...the "customer_payment" entity is a legacy from sample data. It can be deleted only if other custom modules don't use it. It is strongly recommended to make DB backups before deleting this entity." – joelmdev Mar 7 '13 at 0:12

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.