function it_adds_multiple_product_values_children_in_the_same_group(ProductValueInterface $valueOne, AttributeInterface $attributeOne, ProductValueInterface $valueTwo, AttributeInterface $attributeTwo, AttributeGroup $group, FormView $valueFormView, $viewUpdaterRegistry) { $valueOne->getAttribute()->willReturn($attributeOne); $valueOne->isRemovable()->willReturn(true); $valueOne->getLocale()->willReturn(null); $valueOne->getEntity()->willReturn(null); $attributeOne->getGroup()->willReturn($group); $attributeOne->getId()->willReturn(42); $attributeOne->getCode()->willReturn('name'); $attributeOne->getLabel()->willReturn('Name'); $attributeOne->getSortOrder()->willReturn(10); $attributeOne->getAttributeType()->willReturn('pim_catalog_text'); $attributeOne->isLocalizable()->willReturn(false); $attributeOne->isScopable()->willReturn(false); $valueTwo->getAttribute()->willReturn($attributeTwo); $valueTwo->isRemovable()->willReturn(true); $valueTwo->getLocale()->willReturn(null); $valueTwo->getEntity()->willReturn(null); $attributeTwo->getGroup()->willReturn($group); $attributeTwo->getId()->willReturn(47); $attributeTwo->getCode()->willReturn('description'); $attributeTwo->getLabel()->willReturn('Description'); $attributeTwo->getSortOrder()->willReturn(15); $attributeTwo->getAttributeType()->willReturn('pim_catalog_text'); $attributeTwo->isLocalizable()->willReturn(false); $attributeTwo->isScopable()->willReturn(false); $group->getId()->willReturn(1); $group->getCode()->willReturn('general'); $group->getLabel()->willReturn('General'); $this->addChildren($valueOne, $valueFormView); $this->addChildren($valueTwo, $valueFormView); $viewUpdaterRegistry->getUpdaters()->willReturn([]); $resultView = [1 => ['label' => 'General', 'attributes' => ['name' => ['id' => 42, 'isRemovable' => true, 'code' => 'name', 'label' => 'Name', 'sortOrder' => 10, 'allowValueCreation' => false, 'locale' => null, 'value' => $valueFormView], 'description' => ['id' => 47, 'isRemovable' => true, 'code' => 'description', 'label' => 'Description', 'sortOrder' => 15, 'allowValueCreation' => false, 'locale' => null, 'value' => $valueFormView]]]]; $this->getView()->shouldReturn($resultView); }
/** * Mark attribute as variant * * @param FormView $view * @param ProductValueInterface $value */ protected function markAttributeAsUpdatedByVariant(FormView $view, ProductValueInterface $value) { $view->vars['from_variant'] = $value->getEntity()->getVariantGroup(); $view->vars['disabled'] = true; $view->vars['read_only'] = true; foreach ($view as $child) { $this->markAttributeAsUpdatedByVariant($child, $value); } }
function it_generates_the_path_when_no_identifier_is_provided(ProductValueInterface $value, ProductInterface $product, FileInfoInterface $fileInfo, AttributeInterface $attribute) { $value->getMedia()->willReturn($fileInfo); $value->getAttribute()->willReturn($attribute); $value->getEntity()->willReturn($product); $product->getIdentifier()->willReturn('sku-product'); $fileInfo->getOriginalFilename()->willReturn('file.jpg'); $attribute->getCode()->willReturn('picture'); $attribute->isLocalizable()->willReturn(false); $attribute->isScopable()->willReturn(false); $this->generate($value, ['identifier' => null])->shouldReturn('files/sku-product/picture/file.jpg'); }
/** * {@inheritdoc} */ public function valueExists(ProductValueInterface $value) { $productQueryBuilder = $this->queryBuilderFactory->create(); $qb = $productQueryBuilder->getQueryBuilder(); $productQueryBuilder->addFilter($value->getAttribute()->getCode(), '=', $value->getData()); $result = $qb->hydrate(false)->getQuery()->execute(); if (0 === $result->count() || 1 === $result->count() && $value->getEntity()->getId() === (string) $result->getNext()['_id']) { return false; } return true; }
function it_marks_product_as_updated_when_a_product_value_is_updated(EntityManager $em, ProductInterface $product, ProductValueInterface $value) { $value->getEntity()->willReturn($product); $this->guessUpdates($em, $value, UpdateGuesserInterface::ACTION_UPDATE_ENTITY)->shouldReturn([$product]); }