/**
  * @param Customer $value
  * @return array
  */
 protected function getRemoteCustomers($value)
 {
     $this->transport->init($value->getChannel()->getTransport());
     $filter = new BatchFilterBag();
     $filter->addComplexFilter('email', ['key' => 'email', 'value' => ['key' => 'eq', 'value' => $value->getEmail()]]);
     $filter->addComplexFilter('store_id', ['key' => 'store_id', 'value' => ['key' => 'eq', 'value' => $value->getStore()->getOriginId()]]);
     $filters = $filter->getAppliedFilters();
     $customers = $this->transport->call(SoapTransport::ACTION_CUSTOMER_LIST, $filters);
     return (array) $customers;
 }
Beispiel #2
0
 /**
  * @param array $ids
  */
 protected function loadEntities(array $ids)
 {
     if (!$ids) {
         return;
     }
     $filters = new BatchFilterBag();
     $filters->addComplexFilter('in', ['key' => $this->getIdFieldName(), 'value' => ['key' => 'in', 'value' => implode(',', $ids)]]);
     if (null !== $this->websiteId && $this->websiteId !== StoresSoapIterator::ALL_WEBSITES) {
         $filters->addWebsiteFilter([$this->websiteId]);
     }
     $this->loadByFilters($filters->getAppliedFilters());
 }
Beispiel #3
0
 /**
  * @param array $ids
  */
 protected function loadEntities(array $ids)
 {
     if (!$ids) {
         return;
     }
     $filters = new BatchFilterBag();
     $filters->addComplexFilter('in', ['key' => $this->getIdFieldName(), 'value' => ['key' => 'in', 'value' => implode(',', $ids)]]);
     if (null !== $this->websiteId && $this->websiteId !== StoresSoapIterator::ALL_WEBSITES) {
         $filters->addStoreFilter($this->getStoresByWebsiteId($this->websiteId));
     }
     $filters = $filters->getAppliedFilters();
     $filters['pager'] = ['page' => $this->getCurrentPage(), 'pageSize' => $this->pageSize];
     $this->loadByFilters($filters);
 }
 /**
  * Process search for removal carts in CRM and mark them as "expired"
  *
  * @param array $ids
  */
 protected function processBatch($ids)
 {
     $filterBag = new BatchFilterBag();
     $filterBag->addStoreFilter($this->stores);
     $filterBag->addComplexFilter('entity_id', ['key' => 'entity_id', 'value' => ['key' => 'in', 'value' => implode(',', array_keys($ids))]]);
     $filters = $filterBag->getAppliedFilters();
     $filters['pager'] = ['page' => 1, 'pageSize' => $this->batchSize];
     $result = $this->transport->call(SoapTransport::ACTION_ORO_CART_LIST, $filters);
     $result = WSIUtils::processCollectionResponse($result);
     $resultIds = array_map(function (&$item) {
         return (int) $item->entity_id;
     }, $result);
     $resultIds = array_flip($resultIds);
     $removedIds = array_values(array_diff_key($ids, $resultIds));
     $this->em->getRepository('OroCRMMagentoBundle:Cart')->markExpired($removedIds);
 }
 /**
  * @param array $websiteIds
  * @param array $storeIds
  */
 protected function applyWebsiteFilters(array $websiteIds, array $storeIds)
 {
     if ($this->websiteId !== StoresSoapIterator::ALL_WEBSITES) {
         if (!empty($websiteIds)) {
             $this->filter->addWebsiteFilter($websiteIds);
         }
         if (!empty($storeIds)) {
             $this->filter->addStoreFilter($storeIds);
         }
     }
 }
 /**
  * @param BatchFilterBag $filter
  */
 protected function applyStoreFilter(BatchFilterBag $filter)
 {
     if ($this->websiteId && $this->websiteId !== StoresSoapIterator::ALL_WEBSITES) {
         $filter->addStoreFilter($this->getStoresByWebsiteId($this->websiteId));
     }
 }
Beispiel #7
0
 /**
  * @param BatchFilterBag $bag
  *
  * @return array
  */
 protected function getAppliedFilters(BatchFilterBag $bag)
 {
     $filters = $bag->getAppliedFilters();
     $this->assertArrayHasKey('filters', $filters);
     $filters = $filters['filters'];
     return $filters;
 }
 /**
  * Add debug records about applied filters to logger
  *
  * @param BatchFilterBag $filterBag
  */
 protected function logAppliedFilters(BatchFilterBag $filterBag)
 {
     $filters = $filterBag->getAppliedFilters();
     $filters = $filters['filters'];
     $filters = array_merge(!empty($filters[BatchFilterBag::FILTER_TYPE_COMPLEX]) ? $filters[BatchFilterBag::FILTER_TYPE_COMPLEX] : [], !empty($filters[BatchFilterBag::FILTER_TYPE_SIMPLE]) ? $filters[BatchFilterBag::FILTER_TYPE_SIMPLE] : []);
     $template = 'Filter applied: %s %s';
     foreach ($filters as $filter) {
         $field = $filter['key'];
         $value = $filter['value'];
         $value = is_array($value) ? http_build_query($value, '', '; ') : '= ' . $value;
         $this->logger->debug(sprintf($template, $field, urldecode($value)));
     }
 }