public function test_write_should_not_update_article_active_flag_if_detail_active_flag_is_given()
 {
     $expectedModifiedArticle = ['orderNumber' => 'SW10123.2', 'mainNumber' => 'SW10123.1', 'active' => '0'];
     $articleWriterResult = $this->articleWriter->write($expectedModifiedArticle, []);
     $isMainArticleActive = $this->getArticlesActiveFlag($articleWriterResult->getArticleId());
     $isDetailActive = $this->getArticleDetailActiveFlag($articleWriterResult->getDetailId());
     $this->assertEquals(0, $isDetailActive, 'Could not update article detail active flag.');
     $this->assertEquals(1, $isMainArticleActive, 'Article active flag was updated, but only article detail should be updated.');
 }
 /**
  * @param array $records
  * @throws \Exception
  */
 private function performImport($records)
 {
     $articleWriter = new ArticleWriter();
     $pricesWriter = new PriceWriter();
     $categoryWriter = new CategoryWriter();
     $configuratorWriter = ConfiguratorWriter::createFromGlobalSingleton();
     $translationWriter = new TranslationWriter();
     $propertyWriter = PropertyWriter::createFromGlobalSingleton();
     $relationWriter = new RelationWriter($this);
     $imageWriter = new ImageWriter($this);
     $defaultValues = $this->getDefaultValues();
     foreach ($records['article'] as $index => $article) {
         try {
             $this->modelManager->getConnection()->beginTransaction();
             $articleWriterResult = $articleWriter->write($article, $defaultValues);
             $processedFlag = isset($article['processed']) && $article['processed'] == 1;
             /**
              * Only processed data will be imported
              */
             if (!$processedFlag) {
                 $pricesWriter->write($articleWriterResult->getArticleId(), $articleWriterResult->getDetailId(), array_filter($records['price'], function ($price) use($index) {
                     return $price['parentIndexElement'] == $index;
                 }));
                 $categoryWriter->write($articleWriterResult->getArticleId(), array_filter($records['category'], function ($category) use($index) {
                     return $category['parentIndexElement'] == $index && ($category['categoryId'] || $category['categoryPath']);
                 }));
                 $configuratorWriter->writeOrUpdateConfiguratorSet($articleWriterResult, array_filter($records['configurator'], function ($configurator) use($index) {
                     return $configurator['parentIndexElement'] == $index;
                 }));
                 $propertyWriter->writeUpdateCreatePropertyGroupsFilterAndValues($articleWriterResult->getArticleId(), $article['orderNumber'], $this->filterPropertyValues($records, $index, $articleWriterResult));
                 $translationWriter->write($articleWriterResult->getArticleId(), $articleWriterResult->getDetailId(), $articleWriterResult->getMainDetailId(), array_filter($records['translation'], function ($translation) use($index) {
                     return $translation['parentIndexElement'] == $index;
                 }));
             }
             /**
              * Processed and unprocessed data will be imported
              */
             if ($processedFlag) {
                 $article['mainNumber'] = $article['orderNumber'];
             }
             $relationWriter->write($articleWriterResult->getArticleId(), $article['mainNumber'], array_filter($records['accessory'], function ($accessory) use($index, $articleWriterResult) {
                 return $accessory['parentIndexElement'] == $index && $articleWriterResult->getMainDetailId() == $articleWriterResult->getDetailId();
             }), 'accessory', $processedFlag);
             $relationWriter->write($articleWriterResult->getArticleId(), $article['mainNumber'], array_filter($records['similar'], function ($similar) use($index, $articleWriterResult) {
                 return $similar['parentIndexElement'] == $index && $articleWriterResult->getMainDetailId() == $articleWriterResult->getDetailId();
             }), 'similar', $processedFlag);
             $imageWriter->write($articleWriterResult->getArticleId(), $article['mainNumber'], array_filter($records['image'], function ($image) use($index) {
                 return $image['parentIndexElement'] == $index;
             }));
             $this->modelManager->getConnection()->commit();
         } catch (AdapterException $e) {
             $this->modelManager->getConnection()->rollBack();
             $message = $e->getMessage();
             $this->saveMessage($message);
         }
     }
 }