Jump to content

I want to add x custumers on Prestashop via code but with extra fields


Stefan Burghelea
 Share

Recommended Posts

I'm trying to add customers with a code but the PrestaShop is giving me a bug. Im using PHP and XML

Code:

 $XMLRQString = '<?xml version="1.0" encoding="utf-8"?>'.
                    '<x:Winmax4GetEntitiesRQ xmlns:x="urn:Winmax4GetEntitiesRQ">'.
                    '</x:Winmax4GetEntitiesRQ >';
                    $Params=array(
                    'CompanyCode'=>'',
                    'UserLogin'=>'',
                    'UserPassword'=>'',
                    'Winmax4GetEntitiesRQXML'=> $XMLRQString
                    );
                    $return = $client->GetEntities($Params);
                    $XMLRSString = new SimpleXMLElement($return->GetEntitiesResult);

            foreach ($XMLRSString->Entities->Entity as $entity)
            {   
                    $default_lang= Configuration::get('PS_LANG_DEFAULT');

                    $customer=new Customer();

                    $customer->email= $entity->Email;

                    $customer->lastname= $entity->EntityType;

                    $customer->firstname= [$default_lang => $entity->Name];

                    $customer->contribuinte= $entity->TaxPayerID;

                    $customer->passwd= $entity->TaxPayerID;

                    $customer->active = 1;

                    $customer->add();
            }

ERROR:

 

(1/1) ContextErrorException

Warning: preg_match() expects parameter 2 to be string, array given

in Validate.php line 172
at ValidateCore::isCustomerName(array('exemplo'))in ObjectModel.php line 1149
at ObjectModelCore->validateField('firstname', array('exemplo'))in ObjectModel.php line 981
at ObjectModelCore->validateFields()in ObjectModel.php line 284
at ObjectModelCore->getFields()in ObjectModel.php line 551
at ObjectModelCore->add(true, true)in Customer.php line 264
at CustomerCore->add()in create_clients.php line 67
Edited by Stefan Burghelea (see edit history)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More