Open TakesTheBiscuit opened 2 months ago
Hi @TakesTheBiscuit thank you for reaching us out. You should take a look at:
and do a mix of both. In the load function of the fixture you should do something like this (just a fast wrap-up i did now, there could be something to adjust):
public function load(ObjectManager $manager)
{
/** @var RepositoryInterface $shippingTableRateRepository */
$shippingTableRateRepository = $this->entityManager->getRepository(ShippingTableRate::class);
$rateIt = new ShippingTableRate();
$rateIt->setName('Tablerate Italy');
$rateIt->setCode('tablerate_italy');
$rateIt->addRate(990, 10);
$rateIt->addRate(1250, 50);
$rateIt->addRate(1500, 100);
$rateIt->addRate(1750, 200);
$shippingTableRateRepository->add($rateIt);
$rateFr = new ShippingTableRate();
$rateFr->setName('Tablerate France');
$rateFr->setCode('tablerate_france');
$rateFr->addRate(1990, 10);
$rateFr->addRate(2250, 50);
$rateFr->addRate(2500, 100);
$rateFr->addRate(2750, 200);
$shippingTableRateRepository->add($rateFr);
/** @var ShippingMethodInterface $shippingMethodIt */
$shippingMethodIt = $this->shippingMethodFactory->createNew();
$shippingMethodIt->setCode('tablerate_italy_shipping');
$shippingMethodIt->setEnabled(true);
$shippingMethodIt->setZone($this->getItalianShippingZone());
$shippingMethodIt->setCalculator(TableRateShippingCalculator::TYPE);
$shippingMethodIt->setConfiguration(['ecommerce' => ['table_rate' => $rateIt]]);
/** @var ShippingMethodInterface $shippingMethodFr */
$shippingMethodFr = $this->shippingMethodFactory->createNew();
$shippingMethodFr->setCode('tablerate_france_shipping');
$shippingMethodFr->setEnabled(true);
$shippingMethodFr->setZone($this->getFranceShippingZone());
$shippingMethodFr->setCalculator(TableRateShippingCalculator::TYPE);
$shippingMethodFr->setConfiguration(['ecommerce' => ['table_rate' => $rateFr]]);
$this->entityManager->flush();
}
Let us know if this helped you
It would be fantastic if you could provide us with an example structure for how we can create a fixture suite which targets webgriffe sylius table rate shipping plugin
This would enable us to set rates for the 10 shipping methods we have all in one go across multiple environments
Thanks!