function let(Group $group, Product $product1, Product $product2, Product $product3, Attribute $attribute1, Attribute $attribute2, AttributeOption $attributeOption11, AttributeOption $attributeOption12, AttributeOption $attributeOption21, AttributeOption $attributeOption22, ProductValue $productValueOption11, ProductValue $productValueOption12, ProductValue $productValueOption21, ProductValue $productValueOption22, ProductValue $productValuePrice1, ProductPrice $productPrice1, ProductValue $productValuePrice2, ProductPrice $productPrice2, ProductValue $productValuePrice3, ProductPrice $productPrice3, MappingCollection $attributeMapping) { $this->beConstructedWith('locale', 'currency'); $group->getAttributes()->willReturn([$attribute1, $attribute2]); //get attribute options $attribute1->getOptions()->willReturn([$attributeOption11, $attributeOption12]); $attribute1->getCode()->willReturn('attribute_1'); $attributeOption11->getAttribute()->willReturn($attribute1); $attributeOption11->getCode()->willReturn('attribute_1_option_1'); $productValueOption11->getData()->willReturn($attributeOption11); $attributeOption12->getAttribute()->willReturn($attribute1); $attributeOption12->getCode()->willReturn('attribute_1_option_2'); $productValueOption12->getData()->willReturn($attributeOption12); $attribute2->getOptions()->willReturn([$attributeOption21, $attributeOption22]); $attribute2->getCode()->willReturn('attribute_2'); $attributeOption21->getAttribute()->willReturn($attribute2); $attributeOption21->getCode()->willReturn('attribute_2_option_1'); $productValueOption21->getData()->willReturn($attributeOption21); $attributeOption22->getAttribute()->willReturn($attribute2); $attributeOption22->getCode()->willReturn('attribute_2_option_2'); $productValueOption22->getData()->willReturn($attributeOption22); //Get product prices $product1->getValue('price', 'locale')->willReturn($productValuePrice1); $product1->getIdentifier()->willReturn('product_1'); $productValuePrice1->getPrice('currency')->willReturn($productPrice1); $productPrice1->getData()->willReturn(5.0); $product2->getValue('price', 'locale')->willReturn($productValuePrice2); $product2->getIdentifier()->willReturn('product_2'); $productValuePrice2->getPrice('currency')->willReturn($productPrice2); $productPrice2->getData()->willReturn(15.0); $product3->getValue('price', 'locale')->willReturn($productValuePrice3); $product3->getIdentifier()->willReturn('product_3'); $productValuePrice3->getPrice('currency')->willReturn($productPrice3); $productPrice3->getData()->willReturn(10.0); $attributeMapping->getSource('attribute_1')->willReturn('attribute_1'); $attributeMapping->getSource('attribute_2')->willReturn('attribute_2'); $attributeMapping->getTarget('attribute_1')->willReturn('attribute_1'); $attributeMapping->getTarget('attribute_2')->willReturn('attribute_2'); }
/** * Get normalized labels for attribute * @param AbstractAttribute $attribute * @param array $magentoStoreViews * @param string $defaultLocale * @param MappingCollection $storeViewMapping * @param MappingCollection $attributeMapping * * @return string */ protected function getNormalizedLabels(AbstractAttribute $attribute, array $magentoStoreViews, $defaultLocale, MappingCollection $storeViewMapping, MappingCollection $attributeMapping) { $localizedLabels = []; foreach ($magentoStoreViews as $magentoStoreView) { $localeCode = $storeViewMapping->getSource($magentoStoreView['code']); $localizedLabels[] = ['store_id' => $magentoStoreView['store_id'], 'label' => $this->getAttributeTranslation($attribute, $localeCode, $defaultLocale)]; } return array_merge([['store_id' => 0, 'label' => strtolower($attributeMapping->getTarget($attribute->getCode()))]], $localizedLabels); }
/** * Get product price from generated mapping * @param ProductInterface $product * @param array $priceChanges * @param float $basePrice * @param MappingCollection $attributeMapping * * @return float */ protected function getProductPriceFromMapping(ProductInterface $product, array $priceChanges, $basePrice, MappingCollection $attributeMapping) { $priceFromMapping = $basePrice; foreach ($priceChanges as $attributeCode => $attributePriceMapping) { $priceFromMapping += $this->getAttributePriceFromMapping($product, $attributeMapping->getSource($attributeCode), $attributePriceMapping); } return $priceFromMapping; }