function it_resolves_association_type_field_names($assocTypeRepo, AssociationTypeInterface $assocType1, AssociationTypeInterface $assocType2)
 {
     $assocType1->getCode()->willReturn("ASSOC_TYPE_1");
     $assocType2->getCode()->willReturn("ASSOC_TYPE_2");
     $assocTypeRepo->findAll()->willReturn([$assocType1, $assocType2]);
     $this->resolveAssociationColumns()->shouldReturn(["ASSOC_TYPE_1-groups", "ASSOC_TYPE_1-products", "ASSOC_TYPE_2-groups", "ASSOC_TYPE_2-products"]);
 }
 function it_returns_association_type_field_names($managerRegistry, AssociationTypeRepositoryInterface $repository, AssociationTypeInterface $assocType1, AssociationTypeInterface $assocType2)
 {
     $assocType1->getCode()->willReturn("ASSOC_TYPE_1");
     $assocType2->getCode()->willReturn("ASSOC_TYPE_2");
     $repository->findAll()->willReturn([$assocType1, $assocType2]);
     $managerRegistry->getRepository(self::ASSOC_TYPE_CLASS)->willReturn($repository);
     $this->getAssociationFieldNames()->shouldReturn(["ASSOC_TYPE_1-groups", "ASSOC_TYPE_1-products", "ASSOC_TYPE_2-groups", "ASSOC_TYPE_2-products"]);
 }
Exemplo n.º 3
0
 function it_returns_association_from_an_association_type_code(Association $assoc1, Association $assoc2, AssociationTypeInterface $assocType1, AssociationTypeInterface $assocType2)
 {
     $assocType1->getCode()->willReturn('ASSOC_TYPE_1');
     $assocType2->getCode()->willReturn('ASSOC_TYPE_2');
     $assoc1->getAssociationType()->willReturn($assocType1);
     $assoc2->getAssociationType()->willReturn($assocType2);
     $this->setAssociations([$assoc1, $assoc2]);
     $this->getAssociationForTypeCode('ASSOC_TYPE_2')->shouldReturn($assoc2);
 }
 function it_retrieves_field_list_with_product_with_attributes($productRepository, $attributeRepository, $assocTypeManager, AttributeInterface $bar, AttributeInterface $baz, AssociationTypeInterface $association)
 {
     $bar->getCode()->willReturn('bar-code');
     $bar->isLocalizable()->willReturn(false);
     $bar->isScopable()->willReturn(false);
     $bar->getAttributeType()->willReturn(null);
     $baz->getCode()->willReturn('baz-code');
     $baz->isLocalizable()->willReturn(false);
     $baz->isScopable()->willReturn(false);
     $baz->getAttributeType()->willReturn(null);
     $association->getCode()->willReturn('association-type-code');
     $assocTypeManager->getAssociationTypes()->willReturn([$association]);
     $productRepository->getAvailableAttributeIdsToExport(['foo'])->willReturn(['bar', 'baz']);
     $attributeRepository->findBy(['id' => ['bar', 'baz']])->willReturn([$bar, $baz]);
     $this->getFieldsList(['foo'])->shouldReturn(["bar-code", "baz-code", "family", "categories", "groups", "association-type-code-groups", "association-type-code-products"]);
 }
 function it_normalizes_product_with_associations($filter, ProductInterface $product, AttributeInterface $skuAttribute, ProductValueInterface $sku, Association $myCrossSell, AssociationTypeInterface $crossSell, Association $myUpSell, AssociationTypeInterface $upSell, GroupInterface $associatedGroup1, GroupInterface $associatedGroup2, ProductInterface $associatedProduct1, ProductInterface $associatedProduct2, ProductValueInterface $skuAssocProduct1, ProductValueInterface $skuAssocProduct2, Collection $values, FamilyInterface $family, $serializer)
 {
     $family->getCode()->willReturn('shoes');
     $skuAttribute->getCode()->willReturn('sku');
     $skuAttribute->getAttributeType()->willReturn('pim_catalog_identifier');
     $skuAttribute->isLocalizable()->willReturn(false);
     $skuAttribute->isScopable()->willReturn(false);
     $sku->getAttribute()->willReturn($skuAttribute);
     $sku->getData()->willReturn('sku-001');
     $crossSell->getCode()->willReturn('cross_sell');
     $myCrossSell->getAssociationType()->willReturn($crossSell);
     $myCrossSell->getGroups()->willReturn([]);
     $myCrossSell->getProducts()->willReturn([]);
     $upSell->getCode()->willReturn('up_sell');
     $myUpSell->getAssociationType()->willReturn($upSell);
     $associatedGroup1->getCode()->willReturn('associated_group1');
     $associatedGroup2->getCode()->willReturn('associated_group2');
     $myUpSell->getGroups()->willReturn([$associatedGroup1, $associatedGroup2]);
     $skuAssocProduct1->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct2->getAttribute()->willReturn($skuAttribute);
     $skuAssocProduct1->__toString()->willReturn('sku_assoc_product1');
     $skuAssocProduct2->__toString()->willReturn('sku_assoc_product2');
     $associatedProduct1->getIdentifier()->willReturn($skuAssocProduct1);
     $associatedProduct2->getIdentifier()->willReturn($skuAssocProduct2);
     $myUpSell->getProducts()->willReturn([$associatedProduct1, $associatedProduct2]);
     $product->getIdentifier()->willReturn($sku);
     $product->getFamily()->willReturn($family);
     $product->isEnabled()->willReturn(true);
     $product->getGroupCodes()->willReturn('group1,group2,variant_group_1');
     $product->getCategoryCodes()->willReturn('nice shoes, converse');
     $product->getAssociations()->willReturn([$myCrossSell, $myUpSell]);
     $product->getValues()->willReturn($values);
     $filter->filterCollection($values, 'pim.transform.product_value.flat', Argument::cetera())->willReturn([$sku]);
     $serializer->normalize($sku, 'flat', Argument::any())->willReturn(['sku' => 'sku-001']);
     $this->normalize($product, 'flat', [])->shouldReturn(['sku' => 'sku-001', 'family' => 'shoes', 'groups' => 'group1,group2,variant_group_1', 'categories' => 'nice shoes, converse', 'cross_sell-groups' => '', 'cross_sell-products' => '', 'up_sell-groups' => 'associated_group1,associated_group2', 'up_sell-products' => 'sku_assoc_product1,sku_assoc_product2', 'enabled' => 1]);
 }
 /**
  * {@inheritdoc}
  */
 public function getAssociationForType(AssociationTypeInterface $type)
 {
     return $this->getAssociationForTypeCode($type->getCode());
 }
 /**
  * {@inheritdoc}
  */
 public function getReference()
 {
     return $this->owner ? $this->owner->getIdentifier() . '.' . $this->associationType->getCode() : null;
 }