Exemplo n.º 1
0
 /**
  * @param string $processName
  *
  * @return array
  */
 public function prepareItems($processName)
 {
     $orderItemsArray = $this->getOrderItems($processName);
     $orders = [];
     $txtArray = [];
     foreach ($orderItemsArray as $orderItemArray) {
         if (!isset($orders[$orderItemArray['orderId']])) {
             $order = new SpySalesOrder();
             $order->setGrandTotal(10000);
             $order->setSubtotal(9900);
             $order->setIsTest(false);
             $address = new SpySalesOrderAddress();
             $address->setLastName('Doe');
             $address->setFirstName('John');
             $address->setCity('Berlin');
             $address->setZipCode('12345');
             $address->setAddress1('Blastr 1');
             $country = SpyCountryQuery::create()->findOneByIdCountry(1);
             $address->setCountry($country);
             $order->setBillingAddress($address);
             $order->setShippingAddress($address);
             $orders[$orderItemArray['orderId']] = $order;
         }
     }
     $states = [];
     $orderItems = [];
     foreach ($orderItemsArray as $orderItemArray) {
         if (isset($states[$orderItemArray['state']])) {
             $state = $states[$orderItemArray['state']];
         } else {
             $state = new SpyOmsOrderItemState();
             $state->setName($orderItemArray['state']);
             $state->save();
             $states[$orderItemArray['state']] = $state;
         }
         $txtArray[] = 'State: ' . $state->getName();
         $process = SpyOmsOrderProcessQuery::create()->filterByName($orderItemArray['process'])->findOneOrCreate();
         $process->setName($orderItemArray['process']);
         $process->save();
         $txtArray[] = 'Process: ' . $process->getName();
         $item = new SpySalesOrderItem();
         $item->setState($state);
         $item->setProcess($process);
         $item->setName('Testproduct');
         $item->setSku('12345ABC');
         $item->setGrossPrice(10);
         $orders[$orderItemArray['orderId']]->addItem($item);
         $orderItems[] = $item;
     }
     foreach ($orderItems as $orderItem) {
         $orderItem->save();
         $txtArray[] = 'orderItem saved: ' . $orderItem->getIdSalesOrderItem();
     }
     return $txtArray;
 }
Exemplo n.º 2
0
 /**
  * @param string $stateName
  *
  * @return \Orm\Zed\Oms\Persistence\SpyOmsOrderItemState
  */
 public function getStateEntity($stateName)
 {
     if (array_key_exists($stateName, self::$stateEntityBuffer)) {
         return self::$stateEntityBuffer[$stateName];
     }
     $stateEntity = SpyOmsOrderItemStateQuery::create()->findOneByName($stateName);
     if (!isset($stateEntity)) {
         $stateEntity = new SpyOmsOrderItemState();
         $stateEntity->setName($stateName);
         $stateEntity->save();
     }
     $stateBuffer[$stateName] = $stateEntity;
     return $stateEntity;
 }
Exemplo n.º 3
0
 /**
  * @param \Orm\Zed\Sales\Persistence\SpySalesOrderItem $orderItem
  * @param string $stateName
  *
  * @return void
  */
 protected function setState($orderItem, $stateName)
 {
     if (isset($this->states[$stateName])) {
         $state = $this->states[$stateName];
     } else {
         $state = SpyOmsOrderItemStateQuery::create()->findOneByName($stateName);
         if (!isset($state)) {
             $state = new SpyOmsOrderItemState();
             $state->setName($stateName);
             $state->save();
         }
         $this->states[$stateName] = $state;
     }
     $orderItem->setState($state);
 }
Exemplo n.º 4
0
 /**
  * @return \Orm\Zed\Oms\Persistence\SpyOmsOrderItemState
  */
 private function createOrderItemStateEntity()
 {
     $stateEntity = new SpyOmsOrderItemState();
     $stateEntity->setName('test item state');
     $stateEntity->save();
     return $stateEntity;
 }
Exemplo n.º 5
0
 /**
  * @return \Orm\Zed\Oms\Persistence\SpyOmsOrderItemState
  */
 protected function createOmsState()
 {
     $omsStateEntity = new SpyOmsOrderItemState();
     $omsStateEntity->setName(self::DEFAULT_ITEM_STATE);
     $omsStateEntity->save();
     return $omsStateEntity;
 }