Ejemplo n.º 1
0
 public function isModuleDpdPickup(OrderEvent $event)
 {
     $address = AddressIcirelaisQuery::create()->findPk($event->getDeliveryAddress());
     if ($this->check_module($event->getDeliveryModule())) {
         //tmp solution
         $request = $this->getRequest();
         $pr_code = $request->request->get('pr_code');
         if (!empty($pr_code)) {
             // Get details w/ SOAP
             $con = new \SoapClient(__DIR__ . "/../Config/exapaq.wsdl", array('soap_version' => SOAP_1_2));
             $response = $con->GetPudoDetails(array("pudo_id" => $pr_code));
             $xml = new \SimpleXMLElement($response->GetPudoDetailsResult->any);
             if (isset($xml->ERROR)) {
                 throw new \ErrorException("Error while choosing pick-up & go store: " . $xml->ERROR);
             }
             $customer_name = AddressQuery::create()->findPk($event->getDeliveryAddress());
             $request->getSession()->set('DpdPickupDeliveryId', $event->getDeliveryAddress());
             if ($address === null) {
                 $address = new AddressIcirelais();
                 $address->setId($event->getDeliveryAddress());
             }
             // France Métropolitaine
             $address->setCode($pr_code)->setCompany((string) $xml->PUDO_ITEMS->PUDO_ITEM->NAME)->setAddress1((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS1)->setAddress2((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS2)->setAddress3((string) $xml->PUDO_ITEMS->PUDO_ITEM->ADDRESS3)->setZipcode((string) $xml->PUDO_ITEMS->PUDO_ITEM->ZIPCODE)->setCity((string) $xml->PUDO_ITEMS->PUDO_ITEM->CITY)->setFirstname($customer_name->getFirstname())->setLastname($customer_name->getLastname())->setTitleId($customer_name->getTitleId())->setCountryId($customer_name->getCountryId())->save();
         } else {
             throw new \ErrorException("No pick-up & go store chosen for DpdPickup delivery module");
         }
     } elseif (null !== $address) {
         $address->delete();
     }
 }
 /**
  * Exclude object from result
  *
  * @param ChildAddressIcirelais $addressIcirelais Object to remove from the list of results
  *
  * @return ChildAddressIcirelaisQuery The current query, for fluid interface
  */
 public function prune($addressIcirelais = null)
 {
     if ($addressIcirelais) {
         $this->addUsingAlias(AddressIcirelaisTableMap::ID, $addressIcirelais->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }