Пример #1
0
 /**
  * {@inheritdoc}
  */
 protected function getPermissionForAttribute($class, $identifier, $attribute)
 {
     if (is_a($this->object, $this->className, true) && ($attribute === self::ATTRIBUTE_EDIT && (!$this->object->getOriginId() && !$this->object->isGuest()))) {
         return self::ACCESS_DENIED;
     }
     if (is_a($this->object, $this->className, true) && $this->object->getChannel() && !$this->settingsProvider->isChannelApplicable($this->object->getChannel()->getId(), false)) {
         return self::ACCESS_DENIED;
     }
     if (!$this->settingsProvider->hasApplicableChannels(false)) {
         return self::ACCESS_DENIED;
     }
     return self::ACCESS_ABSTAIN;
 }
Пример #2
0
 /**
  * @param Customer $customer
  *
  * @return array
  */
 protected function getModifiedCustomerOrder(Customer $customer)
 {
     return ['increment_id' => '100000307', 'store_id' => $customer->getStore()->getOriginId(), 'created_at' => '2014-05-29 16:41:43', 'updated_at' => '2014-05-29 16:41:43', 'customer_id' => $customer->getOriginId(), 'tax_amount' => '0.0000', 'shipping_amount' => '5.0000', 'discount_amount' => '0.0000', 'subtotal' => '750.0000', 'grand_total' => '755.0000', 'total_qty_ordered' => '1.0000', 'base_tax_amount' => '0.0000', 'base_shipping_amount' => '5.0000', 'base_discount_amount' => '0.0000', 'base_subtotal' => '750.0000', 'base_grand_total' => '755.0000', 'billing_address_id' => '603', 'billing_firstname' => 'asdf', 'billing_lastname' => 'asdf', 'shipping_address_id' => '604', 'shipping_firstname' => 'asdf', 'shipping_lastname' => 'asdf', 'billing_name' => 'asdf asdf', 'shipping_name' => 'asdf asdf', 'store_to_base_rate' => '1.0000', 'store_to_order_rate' => '1.0000', 'base_to_global_rate' => '1.0000', 'base_to_order_rate' => '1.0000', 'weight' => '0.3000', 'store_name' => $customer->getStore()->getName(), 'status' => 'pending', 'state' => 'new', 'global_currency_code' => 'USD', 'base_currency_code' => 'USD', 'store_currency_code' => 'USD', 'order_currency_code' => 'USD', 'shipping_method' => 'flatrate_flatrate', 'shipping_description' => 'Flat Rate - Fixed', 'customer_email' => '*****@*****.**', 'customer_firstname' => 'asdf', 'customer_lastname' => 'asdf', 'quote_id' => '368', 'is_virtual' => '0', 'customer_group_id' => '1', 'customer_note_notify' => '0', 'customer_is_guest' => '0', 'email_sent' => '1', 'order_id' => '302', 'shipping_address' => [], 'billing_address' => [], 'items' => [], 'payment' => '', 'status_history' => [], 'store_code' => $customer->getStore()->getCode(), 'store_storename' => $customer->getStore()->getName(), 'store_website_id' => $customer->getStore()->getWebsite()->getOriginId(), 'store_website_code' => $customer->getStore()->getWebsite()->getCode(), 'store_website_name' => $customer->getStore()->getWebsite()->getName()];
 }
Пример #3
0
 /**
  * {@inheritdoc}
  */
 public function getCustomerAddresses(Customer $customer)
 {
     $customerId = $customer->getOriginId();
     $addresses = $this->call(SoapTransport::ACTION_CUSTOMER_ADDRESS_LIST, ['customerId' => $customerId]);
     $addresses = WSIUtils::processCollectionResponse($addresses);
     return $addresses;
 }
Пример #4
0
 /**
  * @Route(
  *   "/customer_sync/{id}",
  *   name="orocrm_magento_orderplace_new_customer_order_sync", requirements={"id"="\d+"})
  * )
  * @AclAncestor("oro_workflow")
  * @param Customer $customer
  * @return JsonResponse
  */
 public function customerSyncAction(Customer $customer)
 {
     $em = $this->get('doctrine.orm.entity_manager');
     try {
         $isOrderLoaded = $this->loadOrderInformation($customer->getChannel(), ['filters' => ['customer_id' => $customer->getOriginId()]]);
         if (!$isOrderLoaded) {
             throw new \LogicException('Unable to load order.');
         }
         $order = $em->getRepository('OroCRMMagentoBundle:Order')->getLastPlacedOrderBy($customer, 'customer');
         if (null === $order) {
             throw new \LogicException('Unable to load order.');
         }
         $redirectUrl = $this->generateUrl('orocrm_magento_order_view', ['id' => $order->getId()]);
         $message = $this->get('translator')->trans('orocrm.magento.controller.synchronization_success');
         $status = self::SYNC_SUCCESS;
     } catch (\Exception $e) {
         $redirectUrl = $this->generateUrl('orocrm_magento_customer_view', ['id' => $customer->getId()]);
         $message = $this->get('translator')->trans('orocrm.magento.controller.sync_error_with_magento');
         $status = self::SYNC_ERROR;
     }
     return new JsonResponse(['statusType' => $status, 'message' => $message, 'url' => $redirectUrl]);
 }