I am using Magento . I have customer data for my site. Previously I was collecting 12 digit telephone/mobile number while registration i.e. 91xxxxxxxxxx

But because of some reason, from now, I will collect customer numbers only of 10 digits i.e. without 91

So I want to remove 91 from all customer's telephone number from database tables

I do not have any idea where customer telephone numbers are present in Magento database tables

  • I'd not recommend doing it at the DB table, since you can easily mess up any other attributes. Try using Magento collections with some regexp for this. – Prateek Oct 14 '15 at 8:50
  • No that is the requirement. I just only want to remove preceding 91 from numbers.. – ved Oct 14 '15 at 8:52

The easiest way to do this is to knock up a quick script that iterates over all the records in the database and if the first two characters in the target column are 91 remove and update the record.

I was going to suggest a dirty SQL query but it wouldn't account for 91 being in the middle of the string.

You could also, do a NICER script that loads the customer collection and iterates, using the Magento models to handle the data replication to the right tables/columns

  • Thank you for your answer but I do not know how many tables are there is Magento which contains customer telephone number!! – ved Oct 14 '15 at 8:55
  • Iterate the customer model then! AKA neither do I know how many tables contain the number. In theory it should just be the address tables – Barry Carlyon Oct 14 '15 at 8:55
  • Sorry but I am a newbie in Magento.. What should I do by iterating custmoer model? and where? – ved Oct 14 '15 at 8:58
  • If I get time later I'll see about writing up a WHOLE script for you – Barry Carlyon Oct 14 '15 at 9:01
  • while I try to find some way. – ved Oct 14 '15 at 9:02

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.