Exemplo n.º 1
0
 /**
  * @return void
  */
 protected function setData()
 {
     $productAbstract = SpyProductAbstractQuery::create()->filterBySku('test')->findOne();
     if ($productAbstract === null) {
         $productAbstract = new SpyProductAbstract();
         $productAbstract->setSku('test');
     }
     $productAbstract->setAttributes('{}')->save();
     $product = SpyProductQuery::create()->filterBySku('test2')->findOne();
     if ($product === null) {
         $product = new SpyProduct();
         $product->setSku('test2');
     }
     $product->setFkProductAbstract($productAbstract->getIdProductAbstract())->setAttributes('{}')->save();
     $product = SpyProductQuery::create()->filterBySku('test2')->findOne();
     if ($product === null) {
         $product = new SpyProduct();
         $product->setSku('test2');
     }
     $product->setFkProductAbstract($productAbstract->getIdProductAbstract())->setAttributes('{}')->save();
     $stockType1 = SpyStockQuery::create()->filterByName('warehouse1')->findOneOrCreate();
     $stockType1->setName('warehouse1')->save();
     $stockType2 = SpyStockQuery::create()->filterByName('warehouse2')->findOneOrCreate();
     $stockType2->setName('warehouse2')->save();
     $stockProduct1 = SpyStockProductQuery::create()->filterByFkStock($stockType1->getIdStock())->filterByFkProduct($product->getIdProduct())->findOneOrCreate();
     $stockProduct1->setFkStock($stockType1->getIdStock())->setQuantity(10)->setFkProduct($product->getIdProduct())->save();
     $stockProduct2 = SpyStockProductQuery::create()->filterByFkStock($stockType2->getIdStock())->filterByFkProduct($product->getIdProduct())->findOneOrCreate();
     $stockProduct2->setFkStock($stockType2->getIdStock())->setQuantity(20)->setFkProduct($product->getIdProduct())->save();
 }
 /**
  * @return void
  */
 public function testPluginExpandsCartItemWithExpectedProductData()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $changeTransfer = new CartChangeTransfer();
     $itemTransfer = new ItemTransfer();
     $itemTransfer->setSku(self::SKU_PRODUCT_CONCRETE);
     $changeTransfer->addItem($itemTransfer);
     $this->productCartConnectorFacade->expandItems($changeTransfer);
     $expandedItemTransfer = $changeTransfer->getItems()[0];
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $expandedItemTransfer->getAbstractSku());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $expandedItemTransfer->getSku());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $expandedItemTransfer->getIdProductAbstract());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $expandedItemTransfer->getId());
 }
Exemplo n.º 3
0
 /**
  * @return void
  */
 protected function setTestData()
 {
     $priceType1 = SpyPriceTypeQuery::create()->filterByName(self::DUMMY_PRICE_TYPE_1)->findOneOrCreate();
     $priceType1->setName(self::DUMMY_PRICE_TYPE_1)->save();
     $priceType2 = SpyPriceTypeQuery::create()->filterByName(self::DUMMY_PRICE_TYPE_2)->findOneOrCreate();
     $priceType2->setName(self::DUMMY_PRICE_TYPE_2)->save();
     $productAbstract = SpyProductAbstractQuery::create()->filterBySku(self::DUMMY_SKU_PRODUCT_ABSTRACT)->findOne();
     if ($productAbstract === null) {
         $productAbstract = new SpyProductAbstract();
     }
     $productAbstract->setSku(self::DUMMY_SKU_PRODUCT_ABSTRACT)->setAttributes('{}')->save();
     $productConcrete = SpyProductQuery::create()->filterBySku(self::DUMMY_SKU_PRODUCT_CONCRETE)->findOne();
     if ($productConcrete === null) {
         $productConcrete = new SpyProduct();
     }
     $productConcrete->setSku(self::DUMMY_SKU_PRODUCT_CONCRETE)->setAttributes('{}')->setSpyProductAbstract($productAbstract)->save();
     $this->deletePriceEntitiesConcrete($productConcrete);
     $productConcrete->setSku(self::DUMMY_SKU_PRODUCT_CONCRETE)->setAttributes('{}')->setSpyProductAbstract($productAbstract)->save();
     $this->deletePriceEntitiesAbstract($productAbstract);
 }
Exemplo n.º 4
0
 /**
  * @return \Generated\Shared\Transfer\QuoteTransfer
  */
 protected function getBaseQuoteTransfer()
 {
     $quoteTransfer = new QuoteTransfer();
     $country = new SpyCountry();
     $country->setIso2Code('xi')->save();
     $productAbstract1 = new SpyProductAbstract();
     $productAbstract1->setSku('AOSB1337')->setAttributes('{}');
     $productConcrete1 = new SpyProduct();
     $productConcrete1->setSku('OSB1337')->setAttributes('{}')->setSpyProductAbstract($productAbstract1)->save();
     $productAbstract2 = new SpyProductAbstract();
     $productAbstract2->setSku('AOSB1338')->setAttributes('{}');
     $productConcrete2 = new SpyProduct();
     $productConcrete2->setSku('OSB1338')->setSpyProductAbstract($productAbstract2)->setAttributes('{}')->save();
     $stock = new SpyStock();
     $stock->setName('testStock');
     $stock1 = new SpyStockProduct();
     $stock1->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete1)->save();
     $stock2 = new SpyStockProduct();
     $stock2->setQuantity(1)->setStock($stock)->setSpyProduct($productConcrete2)->save();
     $item1 = new ItemTransfer();
     $item1->setSku('OSB1337')->setQuantity(1)->setUnitGrossPrice(3000)->setName('Product1');
     $item2 = new ItemTransfer();
     $item2->setSku('OSB1338')->setQuantity(1)->setUnitGrossPrice(4000)->setName('Product2');
     $quoteTransfer->addItem($item1);
     $quoteTransfer->addItem($item2);
     $totals = new TotalsTransfer();
     $totals->setGrandTotal(1000)->setSubtotal(500);
     $quoteTransfer->setTotals($totals);
     $billingAddress = new AddressTransfer();
     $shippingAddress = new AddressTransfer();
     $billingAddress->setIso2Code('xi')->setEmail('*****@*****.**')->setFirstName('Max')->setLastName('Mustermann')->setAddress1('Straße')->setAddress2('82')->setZipCode('12345')->setCity('Entenhausen');
     $shippingAddress->setIso2Code('xi')->setFirstName('Max')->setLastName('Mustermann')->setEmail('*****@*****.**')->setAddress1('Straße')->setAddress2('84')->setZipCode('12346')->setCity('Entenhausen2');
     $quoteTransfer->setBillingAddress($billingAddress);
     $quoteTransfer->setShippingAddress($shippingAddress);
     $customerTransfer = new CustomerTransfer();
     $customerTransfer->setIsGuest(false)->setEmail('*****@*****.**');
     $quoteTransfer->setCustomer($customerTransfer);
     $shipment = new ShipmentTransfer();
     $shipment->setMethod(new ShipmentMethodTransfer());
     $quoteTransfer->setShipment($shipment);
     $paymentTransfer = new PaymentTransfer();
     $paymentTransfer->setPaymentSelection('no_payment');
     $quoteTransfer->setPayment($paymentTransfer);
     return $quoteTransfer;
 }
Exemplo n.º 5
0
 /**
  * @param \Generated\Shared\Transfer\ProductAbstractTransfer $productAbstractTransfer
  *
  * @return int
  */
 public function createProductAbstract(ProductAbstractTransfer $productAbstractTransfer)
 {
     $sku = $productAbstractTransfer->getSku();
     $encodedAttributes = $this->encodeAttributes($productAbstractTransfer->getAttributes());
     $productAbstract = new SpyProductAbstract();
     $productAbstract->setAttributes($encodedAttributes)->setSku($sku);
     $productAbstract->save();
     $idProductAbstract = $productAbstract->getPrimaryKey();
     $productAbstractTransfer->setIdProductAbstract($idProductAbstract);
     $this->createProductAbstractAttributes($productAbstractTransfer);
     $this->createProductAbstractImages($productAbstractTransfer);
     return $idProductAbstract;
 }
Exemplo n.º 6
0
 /**
  * @group Product
  *
  * @return void
  */
 public function testGetProductConcrete()
 {
     $localeName = Store::getInstance()->getCurrentLocale();
     $localeTransfer = $this->localeFacade->getLocale($localeName);
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(self::TAX_RATE_PERCENTAGE)->setName(self::TAX_RATE_NAME);
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->addSpyTaxRate($taxRateEntity)->setName(self::TAX_SET_NAME);
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSpyTaxSet($taxSetEntity)->setAttributes('')->setSku(self::SKU_PRODUCT_ABSTRACT);
     $localizedAttributesEntity = new SpyProductLocalizedAttributes();
     $localizedAttributesEntity->setName(self::PRODUCT_CONCRETE_NAME)->setAttributes('')->setFkLocale($localeTransfer->getIdLocale());
     $productConcreteEntity = new SpyProduct();
     $productConcreteEntity->setSpyProductAbstract($productAbstractEntity)->setAttributes('')->addSpyProductLocalizedAttributes($localizedAttributesEntity)->setSku(self::SKU_PRODUCT_CONCRETE)->save();
     $productConcreteTransfer = $this->productFacade->getProductConcrete($productConcreteEntity->getSku());
     $this->assertEquals(self::PRODUCT_CONCRETE_NAME, $productConcreteTransfer->getName());
     $this->assertEquals(self::SKU_PRODUCT_CONCRETE, $productConcreteTransfer->getSku());
     $this->assertEquals(self::SKU_PRODUCT_ABSTRACT, $productConcreteTransfer->getProductAbstractSku());
     $this->assertEquals($productConcreteEntity->getIdProduct(), $productConcreteTransfer->getIdProductConcrete());
     $this->assertEquals($productAbstractEntity->getIdProductAbstract(), $productConcreteTransfer->getIdProductAbstract());
 }
Exemplo n.º 7
0
 /**
  * @return array
  */
 public static function loadFixtures()
 {
     $ids = [];
     $dbConnection = Propel::getConnection();
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(10)->setName('Foo');
     $taxRateEntity->save();
     $ids['idTaxRate1'] = $taxRateEntity->getIdTaxRate();
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(5)->setName('Bar');
     $taxRateEntity->save();
     $ids['idTaxRate2'] = $taxRateEntity->getIdTaxRate();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName('Baz');
     $taxSetEntity->save();
     $ids['idTaxSet'] = $taxSetEntity->getIdTaxSet();
     $taxSetTaxEntity = new SpyTaxSetTax();
     $taxSetTaxEntity->setFkTaxSet($ids['idTaxSet'])->setFkTaxRate($ids['idTaxRate1']);
     $taxSetTaxEntity->save();
     $taxSetTaxEntity = new SpyTaxSetTax();
     $taxSetTaxEntity->setFkTaxSet($ids['idTaxSet'])->setFkTaxRate($ids['idTaxRate2']);
     $taxSetTaxEntity->save();
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSku('ABC123')->setFkTaxSet($ids['idTaxSet'])->setAttributes('{}');
     $productAbstractEntity->save();
     $ids['idProductAbstract'] = $productAbstractEntity->getIdProductAbstract();
     $productEntity = new SpyProduct();
     $productEntity->setSku('DEF456')->setFkProductAbstract($ids['idProductAbstract'])->setAttributes('{}');
     $productEntity->save();
     $ids['idProductConcrete'] = $productEntity->getIdProduct();
     $productOptionTypeEntity = new SpyProductOptionType();
     $productOptionTypeEntity->save();
     $ids['idTypeColor'] = $productOptionTypeEntity->getIdProductOptionType();
     $productOptionTypeEntity = new SpyProductOptionType();
     $productOptionTypeEntity->setFkTaxSet($ids['idTaxSet']);
     $productOptionTypeEntity->save();
     $ids['idTypeSize'] = $productOptionTypeEntity->getIdProductOptionType();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueRed'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueBlue'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueGreen'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueYellow'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValuePriceEntity = new SpyProductOptionValuePrice();
     $productOptionValuePriceEntity->setPrice(199);
     $productOptionValuePriceEntity->save();
     $ids['idPriceLarge'] = $productOptionValuePriceEntity->getIdProductOptionValuePrice();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize'])->setFkProductOptionValuePrice($ids['idPriceLarge']);
     $productOptionValueEntity->save();
     $ids['idValueLarge'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueSmall'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueMedium'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueXSmall'] = $productOptionValueEntity->getIdProductOptionValue();
     $localeEntity = new SpyLocale();
     $localeEntity->setLocaleName('xx_XX');
     $localeEntity->save();
     $ids['idLocale'] = $localeEntity->getIdLocale();
     $productOptionTypeTranslationEntity = new SpyProductOptionTypeTranslation();
     $productOptionTypeTranslationEntity->setName('Size')->setFkLocale($ids['idLocale'])->setFkProductOptionType($ids['idTypeSize']);
     $productOptionTypeTranslationEntity->save();
     $productOptionTypeTranslationEntity = new SpyProductOptionTypeTranslation();
     $productOptionTypeTranslationEntity->setName('Color')->setFkLocale($ids['idLocale'])->setFkProductOptionType($ids['idTypeColor']);
     $productOptionTypeTranslationEntity->save();
     $data = ['Blue' => $ids['idValueBlue'], 'Red' => $ids['idValueRed'], 'Yellow' => $ids['idValueYellow'], 'Green' => $ids['idValueGreen'], 'Large' => $ids['idValueLarge'], 'Medium' => $ids['idValueMedium'], 'Small' => $ids['idValueSmall'], 'Extra' => $ids['idValueXSmall']];
     foreach ($data as $name => $fkProductOptionValue) {
         $productOptionValueTranslationEntity = new SpyProductOptionValueTranslation();
         $productOptionValueTranslationEntity->setName($name)->setFkLocale($ids['idLocale'])->setFkProductOptionValue($fkProductOptionValue);
         $productOptionValueTranslationEntity->save();
     }
     $productOptionTypeUsageEntity = new SpyProductOptionTypeUsage();
     $productOptionTypeUsageEntity->setIsOptional(0)->setSequence(1)->setFkProduct($ids['idProductConcrete'])->setFkProductOptionType($ids['idTypeColor']);
     $productOptionTypeUsageEntity->save();
     $ids['idUsageColor'] = $productOptionTypeUsageEntity->getIdProductOptionTypeUsage();
     $productOptionTypeUsageEntity = new SpyProductOptionTypeUsage();
     $productOptionTypeUsageEntity->setIsOptional(0)->setSequence(1)->setFkProduct($ids['idProductConcrete'])->setFkProductOptionType($ids['idTypeSize']);
     $productOptionTypeUsageEntity->save();
     $ids['idUsageSize'] = $productOptionTypeUsageEntity->getIdProductOptionTypeUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(1)->setFkProductOptionValue($ids['idValueBlue'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageBlue'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(2)->setFkProductOptionValue($ids['idValueRed'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageRed'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(3)->setFkProductOptionValue($ids['idValueYellow'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageYellow'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(4)->setFkProductOptionValue($ids['idValueGreen'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageGreen'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(1)->setFkProductOptionValue($ids['idValueLarge'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageLarge'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(2)->setFkProductOptionValue($ids['idValueMedium'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageMedium'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(3)->setFkProductOptionValue($ids['idValueSmall'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageSmall'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(4)->setFkProductOptionValue($ids['idValueXSmall'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageXSmall'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionTypeUsageExclusionEntity = new SpyProductOptionTypeUsageExclusion();
     $productOptionTypeUsageExclusionEntity->setFkProductOptionTypeUsageA($ids['idUsageColor'])->setFkProductOptionTypeUsageB($ids['idUsageSize']);
     $productOptionTypeUsageExclusionEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageBlue'])->setFkProductOptionValueUsageB($ids['idUsageSmall'])->setOperator('NOT');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageRed'])->setFkProductOptionValueUsageB($ids['idUsageMedium'])->setOperator('ALWAYS');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageGreen'])->setFkProductOptionValueUsageB($ids['idUsageSmall'])->setOperator('ALLOW');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageGreen'])->setFkProductOptionValueUsageB($ids['idUsageLarge'])->setOperator('ALLOW');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionConfigurationPresetEntity = new SpyProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity->setIsDefault(true)->setSequence(1)->setFkProduct($ids['idProductConcrete']);
     $productOptionConfigurationPresetEntity->save();
     $ids['idConfigPresetA'] = $productOptionConfigurationPresetEntity->getIdProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity = new SpyProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity->setIsDefault(false)->setSequence(2)->setFkProduct($ids['idProductConcrete']);
     $productOptionConfigurationPresetEntity->save();
     $ids['idConfigPresetB'] = $productOptionConfigurationPresetEntity->getIdProductOptionConfigurationPreset();
     $data = [$ids['idUsageRed'] => $ids['idConfigPresetA'], $ids['idUsageMedium'] => $ids['idConfigPresetA'], $ids['idUsageGreen'] => $ids['idConfigPresetB'], $ids['idUsageLarge'] => $ids['idConfigPresetB']];
     foreach ($data as $fkProductOptionValueUsage => $fkProductOptionConfigurationPreset) {
         $productOptionConfigurationPresetValueEntity = new SpyProductOptionConfigurationPresetValue();
         $productOptionConfigurationPresetValueEntity->setFkProductOptionConfigurationPreset($fkProductOptionConfigurationPreset)->setFkProductOptionValueUsage($fkProductOptionValueUsage);
         $productOptionConfigurationPresetValueEntity->save();
     }
     return $ids;
 }
Exemplo n.º 8
0
 /**
  * @param \Orm\Zed\Product\Persistence\SpyProductAbstract $abstractProductEntity
  * @param \Orm\Zed\Product\Persistence\SpyProductAbstractLocalizedAttributes $localizedAttributeEntity
  * @param array $abstractProductAttributes
  *
  * @return \Generated\Shared\Transfer\ProductVariantTransfer
  */
 protected function hydrateAbstractProductVariant(SpyProductAbstract $abstractProductEntity, SpyProductAbstractLocalizedAttributes $localizedAttributeEntity, array $abstractProductAttributes)
 {
     $productVariantTransfer = new ProductVariantTransfer();
     $abstractProduct = $abstractProductEntity->toArray();
     unset($abstractProduct['attributes']);
     $productVariantTransfer->fromArray($abstractProduct, true);
     $localizedAttributes = $localizedAttributeEntity->toArray();
     unset($localizedAttributes['attributes']);
     $productVariantTransfer->fromArray($localizedAttributes, true);
     $productVariantTransfer->setLocaleName($localizedAttributeEntity->getLocale()->getLocaleName());
     $localizedAttributes = array_merge($abstractProductAttributes, Json::decode($localizedAttributeEntity->getAttributes(), true));
     $productVariantTransfer->setAttributes($localizedAttributes);
     return $productVariantTransfer;
 }
 /**
  * @return void
  */
 private function loadFixtures()
 {
     $rate1 = new SpyTaxRate();
     $rate1->setName('Rate1')->setRate(10)->save();
     $this->taxRateIds[] = $rate1->getIdTaxRate();
     $rate2 = new SpyTaxRate();
     $rate2->setName('Rate2')->setRate(5)->save();
     $this->taxRateIds[] = $rate2->getIdTaxRate();
     $taxSet = new SpyTaxSet();
     $taxSet->setName('Set1')->addSpyTaxRate($rate1)->addSpyTaxRate($rate2)->save();
     $this->taxSetId = $taxSet->getIdTaxSet();
     $product1 = new SpyProductAbstract();
     $product1->setSku('Product1')->setSpyTaxSet($taxSet)->setAttributes('{}')->save();
     $this->productAbstractIds[] = $product1->getIdProductAbstract();
     $product2 = new SpyProductAbstract();
     $product2->setSku('Product2')->setSpyTaxSet($taxSet)->setAttributes('{}')->save();
     $this->productAbstractIds[] = $product2->getIdProductAbstract();
 }
Exemplo n.º 10
0
 /**
  * @api
  *
  * @todo refactor queries from below
  *
  * @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstract
  *
  * @return \Orm\Zed\Product\Persistence\SpyProductQuery
  */
 public function queryProductConcreteByProductAbstract(SpyProductAbstract $productAbstract)
 {
     return $this->getFactory()->createProductQuery()->filterByFkProductAbstract($productAbstract->getIdProductAbstract());
 }
Exemplo n.º 11
0
 /**
  * @param int $taxRate
  * @param string $iso2Code
  *
  * @return \Orm\Zed\Product\Persistence\SpyProductAbstract
  */
 protected function createAbstractProductWithTaxSet($taxRate, $iso2Code)
 {
     $countryEntity = SpyCountryQuery::create()->findOneByIso2Code($iso2Code);
     $taxRateEntity1 = new SpyTaxRate();
     $taxRateEntity1->setRate($taxRate);
     $taxRateEntity1->setName('test rate');
     $taxRateEntity1->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity1->save();
     $taxRateEntity2 = new SpyTaxRate();
     $taxRateEntity2->setRate(13);
     $taxRateEntity2->setName('test rate');
     $taxRateEntity2->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity2->save();
     $taxRateExemptEntity = new SpyTaxRate();
     $taxRateExemptEntity->setRate(0);
     $taxRateExemptEntity->setName(TaxConstants::TAX_EXEMPT_PLACEHOLDER);
     $taxRateExemptEntity->save();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName('name of tax set');
     $taxSetEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity1->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity2->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateExemptEntity->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $abstractProductEntity = new SpyProductAbstract();
     $abstractProductEntity->setSku('test-abstract-sku');
     $abstractProductEntity->setAttributes('');
     $abstractProductEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $abstractProductEntity->save();
     return $abstractProductEntity;
 }
Exemplo n.º 12
0
 /**
  * @param \Orm\Zed\Product\Persistence\SpyProductAbstract $productAbstract
  * @param int $idLocale
  *
  * @return array
  */
 protected function getProductCategories(SpyProductAbstract $productAbstract, $idLocale)
 {
     $productCategoryEntityList = $this->getFactory()->getProductCategoryQueryContainer()->queryLocalizedProductCategoryMappingByIdProduct($productAbstract->getIdProductAbstract())->find();
     $categories = [];
     foreach ($productCategoryEntityList as $productCategoryEntity) {
         $categories[] = [self::COL_ID_PRODUCT_CATEGORY => $productCategoryEntity->getIdProductCategory(), self::COL_CATEGORY_NAME => $productCategoryEntity->getSpyCategory()->getLocalisedAttributes($idLocale)->getFirst()->getName()];
     }
     return $categories;
 }