mirror of
https://github.com/retailcrm/prestashop-module.git
synced 2025-03-01 19:03:14 +03:00
Fixed the error with same client addresses (#85)
This commit is contained in:
parent
f8620c9951
commit
41ce30b143
@ -196,6 +196,24 @@ class RetailcrmOrderBuilder
|
||||
return (empty($this->apiSite) || is_bool($this->apiSite)) ? null : $this->apiSite;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear object
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->cmsOrder = null;
|
||||
$this->cmsCart = null;
|
||||
$this->cmsCustomer = null;
|
||||
$this->invoiceAddress = null;
|
||||
$this->deliveryAddress = null;
|
||||
$this->createdCustomer = null;
|
||||
$this->corporateCompanyExtractCache = null;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns order with prepared customer data. Customer is created if it's not exist, shouldn't be called to just
|
||||
* build order.
|
||||
|
@ -65,11 +65,21 @@ class RetailcrmExportEvent extends RetailcrmAbstractEvent implements RetailcrmEv
|
||||
$orderBuilder->defaultLangFromConfiguration()->setApi($api);
|
||||
|
||||
foreach ($orderRecords as $record) {
|
||||
$orderBuilder->reset();
|
||||
|
||||
$order = new Order($record['id_order']);
|
||||
|
||||
$orderCart = new Cart($order->id_cart);
|
||||
$orderCustomer = new Customer($order->id_customer);
|
||||
|
||||
$orderBuilder->setCmsOrder($order);
|
||||
|
||||
if (!empty($orderCart->id)) {
|
||||
$orderBuilder->setCmsCart($orderCart);
|
||||
} else {
|
||||
$orderBuilder->setCmsCart(null);
|
||||
}
|
||||
|
||||
if (!empty($orderCustomer->id)) {
|
||||
$orderBuilder->setCmsCustomer($orderCustomer);
|
||||
} else {
|
||||
@ -79,14 +89,6 @@ class RetailcrmExportEvent extends RetailcrmAbstractEvent implements RetailcrmEv
|
||||
$orderBuilder->setCmsCustomer(null);
|
||||
}
|
||||
|
||||
if (!empty($orderCart->id)) {
|
||||
$orderBuilder->setCmsCart($orderCart);
|
||||
} else {
|
||||
$orderBuilder->setCmsCart(null);
|
||||
}
|
||||
|
||||
$orderBuilder->setCmsOrder($order);
|
||||
|
||||
try {
|
||||
$orders[] = $orderBuilder->buildOrderWithPreparedCustomer();
|
||||
} catch (\InvalidArgumentException $exception) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user