/**
  * @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;
 }
 /**
  * @param int $taxRate
  * @param string $iso2Code
  *
  * @return \Orm\Zed\Shipment\Persistence\SpyShipmentMethod
  */
 protected function createShipmentMethodWithTaxSet($taxRate, $iso2Code)
 {
     $countryEntity = SpyCountryQuery::create()->findOneByIso2Code($iso2Code);
     $taxRateEntity1 = new SpyTaxRate();
     $taxRateEntity1->setRate($taxRate);
     $taxRateEntity1->setName('test rate 1');
     $taxRateEntity1->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity1->save();
     $taxRateEntity2 = new SpyTaxRate();
     $taxRateEntity2->setRate(13);
     $taxRateEntity2->setName('tax rate 2');
     $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();
     $shipmentCarrierEntity = new SpyShipmentCarrier();
     $shipmentCarrierEntity->setName('name carrier');
     $shipmentCarrierEntity->save();
     $shipmentMethodEntity = new SpyShipmentMethod();
     $shipmentMethodEntity->setFkShipmentCarrier($shipmentCarrierEntity->getIdShipmentCarrier());
     $shipmentMethodEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $shipmentMethodEntity->setName('test shipment method');
     $shipmentMethodEntity->save();
     return $shipmentMethodEntity;
 }
Esempio n. 3
0
 /**
  * @return \Orm\Zed\Tax\Persistence\SpyTaxSet
  */
 private function loadFixtures()
 {
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setName(self::DUMMY_TAX_RATE1_NAME);
     $taxRateEntity->setRate(self::DUMMY_TAX_RATE1_PERCENTAGE);
     $taxRateEntity->save();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName(self::DUMMY_TAX_SET_NAME);
     $taxSetEntity->addSpyTaxRate($taxRateEntity);
     $taxSetEntity->save();
     return $taxSetEntity;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 /**
  * @param \Generated\Shared\Transfer\TaxRateTransfer $taxRateTransfer
  *
  * @return \Orm\Zed\Tax\Persistence\SpyTaxRate
  */
 private function createTaxRateEntity(TaxRateTransfer $taxRateTransfer)
 {
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->fromArray($taxRateTransfer->toArray());
     if ($taxRateTransfer->getFkCountry() === 0) {
         $taxRateEntity->setFkCountry(null);
     }
     $taxRateEntity->save();
     return $taxRateEntity;
 }