Exemplo n.º 1
0
 public function testReset()
 {
     // add only last id filter
     $this->filter->addLastIdFilter(1);
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertCount(1, $filters['complex_filter']);
     // add date filter in initial mode
     $this->filter->addDateFilter('created_at', 'to', new \DateTime());
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertCount(2, $filters['complex_filter']);
     // add dummy simple filter
     $this->filter->addFilter('test', ['test' => true]);
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertCount(1, $filters['filter']);
     // reset only simple filter
     $this->filter->reset('filter');
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertArrayNotHasKey('filter', $filters);
     $this->filter->reset();
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertArrayNotHasKey('complex_filter', $filters);
     $this->assertArrayNotHasKey('filter', $filters);
     // add dummy simple filter
     $this->filter->addFilter('test', ['test' => true]);
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertCount(1, $filters['filter']);
     $this->filter->reset(BatchFilterBag::FILTER_TYPE_SIMPLE, 'test');
     $filters = $this->getAppliedFilters($this->filter);
     $this->assertFalse(isset($filters['filter']['test']));
 }
Exemplo n.º 2
0
 /**
  * @param \DateTime $date
  * @param array     $websiteIds
  * @param array     $storeIds
  * @param string    $format
  *
  * @return array
  */
 protected function getBatchFilter(\DateTime $date, array $websiteIds = [], array $storeIds = [], $format = 'Y-m-d H:i:s')
 {
     if ($this->websiteId !== StoresSoapIterator::ALL_WEBSITES) {
         if (!empty($websiteIds)) {
             $this->filter->addWebsiteFilter($websiteIds);
         }
         if (!empty($storeIds)) {
             $this->filter->addStoreFilter($storeIds);
         }
     }
     $initMode = $this->mode == self::IMPORT_MODE_INITIAL;
     if ($initMode) {
         $dateField = 'created_at';
         $dateKey = 'to';
     } else {
         $dateField = 'updated_at';
         $dateKey = 'from';
     }
     $this->filter->addDateFilter($dateField, $dateKey, $date, $format);
     $lastId = $this->getLastId();
     if (!is_null($lastId) && $initMode) {
         $this->filter->addLastIdFilter($lastId, $this->getIdFieldName());
     }
     $this->logAppliedFilters($this->filter);
     return $this->filter->getAppliedFilters();
 }