/**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $this->versionManager->setRealTimeVersioning($this->realTimeVersioning);
     foreach ($items as $item) {
         $this->incrementCount($item);
     }
     $this->productSaver->saveAll($items, ['recalculate' => false]);
     $this->detacher->detachAll($items);
 }
 /**
  * {@inheritdoc}
  *
  * We need to save a default group because all attributes must have a group.
  *
  * For example, we want to remove the price attribute from the product information group. We must put it
  * in the default group so we make sure it is always saved
  */
 public function write(array $objects)
 {
     $this->incrementCount($objects);
     if (null !== ($defaultGroup = $this->attributeGroupRepository->findDefaultAttributeGroup())) {
         $objects[] = $defaultGroup;
     }
     $this->bulkSaver->saveAll($objects);
     $this->bulkDetacher->detachAll($objects);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $variantGroups)
 {
     $jobParameters = $this->stepExecution->getJobParameters();
     $isCopyValues = $jobParameters->get('copyValues');
     if ($isCopyValues) {
         $this->copyValuesToProducts($variantGroups);
     }
     $this->incrementCount($variantGroups);
     $this->bulkSaver->saveAll($variantGroups);
     $this->bulkDetacher->detachAll($variantGroups);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $items)
 {
     $jobParameters = $this->stepExecution->getJobParameters();
     $realTimeVersioning = $jobParameters->get('realTimeVersioning');
     $this->versionManager->setRealTimeVersioning($realTimeVersioning);
     foreach ($items as $item) {
         $this->incrementCount($item);
     }
     $this->productSaver->saveAll($items);
     $this->detacher->detachAll($items);
 }
 function it_purges_the_versions_according_to_an_advisor_and_returns_the_number_of_purged_versions(VersionRepositoryInterface $versionRepository, BulkRemoverInterface $versionRemover, BulkObjectDetacherInterface $objectDetacher, VersionPurgerAdvisorInterface $advisor, VersionInterface $versionToBePurged, VersionInterface $versionNotSupported, VersionInterface $versionToNotPurge)
 {
     $versionToBePurged->getResourceName()->willReturn('products');
     $versionToBePurged->getId()->willReturn(1);
     $versionNotSupported->getResourceName()->willReturn('products');
     $versionNotSupported->getId()->willReturn(2);
     $versionToNotPurge->getResourceName()->willReturn('products');
     $versionToNotPurge->getId()->willReturn(3);
     $versionRepository->findPotentiallyPurgeableBy(Argument::type('array'))->willReturn([$versionToBePurged, $versionNotSupported, $versionToNotPurge]);
     $advisor->supports($versionToBePurged)->shouldBeCalled()->willReturn(true);
     $advisor->isPurgeable($versionToBePurged, Argument::type('array'))->shouldBeCalled()->willReturn(true);
     $advisor->supports($versionNotSupported)->shouldBeCalled()->willReturn(false);
     $advisor->isPurgeable($versionNotSupported, Argument::type('array'))->shouldNotBeCalled();
     $advisor->supports($versionToNotPurge)->shouldBeCalled()->willReturn(true);
     $advisor->isPurgeable($versionToNotPurge, Argument::type('array'))->shouldBeCalled()->willReturn(false);
     $this->addVersionPurgerAdvisor($advisor);
     $versionRemover->removeAll([$versionToBePurged, $versionNotSupported])->shouldBeCalled();
     $objectDetacher->detachAll([$versionToBePurged, $versionNotSupported])->shouldBeCalled();
     $objectDetacher->detach($versionToNotPurge)->shouldBeCalled();
     $this->purge([])->shouldReturn(2);
 }
Example #6
0
 /**
  * @param       $group
  * @param array $options
  */
 protected function persistGroup($group, array $options)
 {
     $context = $this->productClassName;
     $this->versionContext->addContextInfo(sprintf('Comes from variant group %s', $group->getCode()), $context);
     if ($group->getType()->isVariant()) {
         $template = $group->getProductTemplate();
         if (null !== $template) {
             $this->templateMediaManager->handleProductTemplateMedia($template);
         }
     }
     $this->objectManager->persist($group);
     $this->saveAssociatedProducts($group);
     if ($group->getType()->isVariant() && true === $options['copy_values_to_products']) {
         $this->copyVariantGroupValues($group);
         $this->detacher->detachAll($group->getProducts()->toArray());
     }
     $this->versionContext->unsetContextInfo($context);
 }
 /**
  * {@inheritdoc}
  */
 public function write(array $objects)
 {
     $this->incrementCount($objects);
     $this->bulkSaver->saveAll($objects);
     $this->bulkDetacher->detachAll($objects);
 }