コード例 #1
0
 function it_renders_a_product_with_an_image($templating, ProductInterface $blender, AttributeGroupInterface $media, AttributeInterface $mainImage)
 {
     $path = realpath(__DIR__ . '/../../../../../features/Context/fixtures/');
     $blender->getAttributes()->willReturn([$mainImage]);
     $mainImage->getGroup()->willReturn($media);
     $media->getLabel()->willReturn('Media');
     $mainImage->getCode()->willReturn('main_image');
     $mainImage->getAttributeType()->willReturn('pim_catalog_image');
     $templating->render(self::TEMPLATE_NAME, ['product' => $blender, 'locale' => 'en_US', 'scope' => 'ecommerce', 'groupedAttributes' => ['Media' => ['main_image' => $mainImage]], 'imageAttributes' => ['main_image' => $mainImage], 'uploadDir' => $path . DIRECTORY_SEPARATOR, 'customFont' => null])->shouldBeCalled();
     $this->render($blender, 'pdf', ['locale' => 'en_US', 'scope' => 'ecommerce']);
 }
コード例 #2
0
 function it_renders_a_product_with_an_image($templating, ProductInterface $blender, AttributeGroupInterface $media, AttributeInterface $mainImage, ProductValueInterface $productValue, FileInfoInterface $fileInfo, CacheManager $cacheManager)
 {
     $path = realpath(__DIR__ . '/../../../../../features/Context/fixtures/');
     $blender->getAttributes()->willReturn([$mainImage]);
     $blender->getValue("main_image", "en_US", "ecommerce")->willReturn($productValue);
     $productValue->getMedia()->willReturn($fileInfo);
     $fileInfo->getKey()->willReturn('fookey');
     $cacheManager->isStored('fookey', 'thumbnail')->willReturn(true);
     $mainImage->getGroup()->willReturn($media);
     $media->getLabel()->willReturn('Media');
     $mainImage->getCode()->willReturn('main_image');
     $mainImage->getAttributeType()->willReturn('pim_catalog_image');
     $templating->render(self::TEMPLATE_NAME, ['product' => $blender, 'locale' => 'en_US', 'scope' => 'ecommerce', 'groupedAttributes' => ['Media' => ['main_image' => $mainImage]], 'imageAttributes' => ['main_image' => $mainImage], 'uploadDir' => $path . DIRECTORY_SEPARATOR, 'customFont' => null])->shouldBeCalled();
     $this->render($blender, 'pdf', ['locale' => 'en_US', 'scope' => 'ecommerce']);
 }
コード例 #3
0
 function let(TranslationNormalizer $transnormalizer, AttributeInterface $attribute, AttributeGroupInterface $attributeGroup)
 {
     $this->beConstructedWith($transnormalizer);
     $transnormalizer->normalize(Argument::cetera())->willReturn([]);
     $attribute->getAttributeType()->willReturn('Yes/No');
     $attribute->getCode()->willReturn('attribute_size');
     $attribute->getGroup()->willReturn($attributeGroup);
     $attributeGroup->getCode()->willReturn('size');
     $attribute->isUnique()->willReturn(true);
     $attribute->isUseableAsGridFilter()->willReturn(false);
     $attribute->getAllowedExtensions()->willReturn(['csv', 'xml', 'json']);
     $attribute->getMetricFamily()->willReturn('Length');
     $attribute->getDefaultMetricUnit()->willReturn('Centimenter');
     $attribute->getReferenceDataName()->willReturn('color');
     $attribute->isLocalizable()->willReturn(true);
     $attribute->isScopable()->willReturn(false);
 }
コード例 #4
0
 /**
  * @param AttributeInterface $attribute
  * @param string             $locale
  *
  * @return ArrayCollection
  */
 protected function getAttributeValues(AttributeInterface $attribute, $locale)
 {
     $group = $attribute->getGroup();
     $key = $attribute->getCode();
     if ($locale) {
         $key .= '_' . $locale;
     }
     if (!isset($this->view[$group->getId()]['attributes'][$key]['values'])) {
         return [];
     }
     return $this->view[$group->getId()]['attributes'][$key]['values'];
 }
コード例 #5
0
 function it_gets_all_product_attributes_and_sets_correct_locale($attributeRepository, $massActionManager, AttributeInterface $attr1, AttributeInterface $attr2, AttributeGroupInterface $attrGroup, LocaleInterface $enLocale)
 {
     $enLocale->getCode()->willReturn('en_US');
     $this->setLocale($enLocale);
     $attributeRepository->findWithGroups([], ['conditions' => ['unique' => 0]])->shouldBeCalled()->willReturn([$attr1, $attr2]);
     $attr1->setLocale('en_US')->shouldBeCalled();
     $attr2->setLocale('en_US')->shouldBeCalled();
     $attr1->getGroup()->willReturn($attrGroup);
     $attr2->getGroup()->willReturn($attrGroup);
     $massActionManager->filterLocaleSpecificAttributes([$attr1, $attr2], 'en_US')->willReturn([$attr1, $attr2]);
     $attrGroup->setLocale('en_US')->shouldBeCalledTimes(2);
     $this->getAllAttributes()->shouldReturn([$attr1, $attr2]);
 }
 /**
  * Hide the group field with a default value = "Other"
  *
  * @param FormInterface      $form Form
  * @param AttributeInterface $data
  */
 protected function hideGroupElement(FormInterface $form, AttributeInterface $data)
 {
     if (null !== $data->getId()) {
         $group = $data->getGroup();
     } else {
         $group = $this->groupRepository->findDefaultAttributeGroup();
     }
     $formField = $form->get('group');
     $options = $formField->getConfig()->getOptions();
     $newOptions = ['data' => $group, 'class' => $options['class'], 'choices' => [$group], 'required' => true, 'multiple' => false, 'read_only' => true, 'attr' => ['class' => 'hide']];
     $form->add('group', 'entity', $newOptions);
 }
コード例 #7
0
 function it_filters_attributes_coming_from_variant_group($massActionManager, $productBuilder, ProductInterface $product1, ProductInterface $product2, AttributeInterface $name, AttributeInterface $name, AttributeInterface $description, AttributeInterface $price, AttributeGroup $otherGroup, ProductValueInterface $nameProductValue, ProductValueInterface $descriptionProductValue, ProductValueInterface $priceProductValue)
 {
     $this->setObjectsToMassEdit([$product1, $product2]);
     $name->getGroup()->willReturn($otherGroup);
     $name->setLocale('en_US')->shouldBeCalled();
     $otherGroup->setLocale('en_US')->shouldBeCalled();
     $description->getGroup()->willReturn($otherGroup);
     $description->setLocale('en_US')->shouldBeCalled();
     $price->getGroup()->willReturn($otherGroup);
     $price->setLocale('en_US')->shouldBeCalled();
     $product1->getId()->willReturn(1);
     $product2->getId()->willReturn(2);
     $name->setLocale(Argument::any())->willReturn($name);
     $name->isScopable()->willReturn(false);
     $name->getCode()->willReturn('name');
     $description->setLocale(Argument::any())->willReturn($description);
     $description->isScopable()->willReturn(false);
     $description->getCode()->willReturn('description');
     $price->setLocale(Argument::any())->willReturn($price);
     $price->isScopable()->willReturn(false);
     $price->getCode()->willReturn('price');
     $this->setObjectsToMassEdit([$product1, $product2]);
     $massActionManager->findCommonAttributes([$product1, $product2])->willReturn([$name, $description, $price]);
     $massActionManager->filterLocaleSpecificAttributes([$name, $description, $price], 'en_US')->willReturn([$name, $description, $price]);
     $massActionManager->filterAttributesComingFromVariant([$name, $description, $price], [$product1, $product2])->willReturn([$name, $price]);
     $productBuilder->createProductValue($name, 'en_US')->willReturn($nameProductValue);
     $productBuilder->addMissingPrices($nameProductValue)->shouldBeCalled();
     $productBuilder->createProductValue($price, 'en_US')->willReturn($priceProductValue);
     $productBuilder->addMissingPrices($priceProductValue)->shouldBeCalled();
     $this->initialize();
     $this->getCommonAttributes()->shouldReturn([$name, $price]);
     $this->getValues()->shouldHaveCount(2);
 }