예제 #1
0
 private function configureChannel(ChannelInterface $channel, $localeCodes = null, $currencyCodes = null, $shippingMethodNames = null, $paymentMethodNames = null, $taxonNames = null)
 {
     if ($shippingMethodNames) {
         $shippingMethodNames = array_map('trim', explode(',', $shippingMethodNames));
         foreach ($shippingMethodNames as $shippingMethodName) {
             $shippingMethod = $shippingMethods = $this->getRepository('shipping_method')->findOneByName($shippingMethodName);
             $channel->addShippingMethod($shippingMethod);
         }
     }
     if ($paymentMethodNames) {
         $paymentMethodNames = array_map('trim', explode(',', $paymentMethodNames));
         foreach ($paymentMethodNames as $paymentMethodName) {
             $paymentMethod = $this->getRepository('payment_method')->findOneByName($paymentMethodName);
             $channel->addPaymentMethod($paymentMethod);
         }
     }
     if ($localeCodes) {
         $localeCodes = array_map('trim', explode(',', $localeCodes));
         $locales = $this->getRepository('locale')->findBy(['code' => $localeCodes]);
         foreach ($locales as $locale) {
             $channel->addLocale($locale);
         }
     }
     if ($currencyCodes) {
         $currencyCodes = array_map('trim', explode(',', $currencyCodes));
         $currencies = $this->getRepository('currency')->findBy(['code' => $currencyCodes]);
         foreach ($currencies as $currency) {
             $channel->addCurrency($currency);
         }
     }
     if ($taxonNames) {
         $taxonNames = array_map('trim', explode(',', $taxonNames));
         foreach ($taxonNames as $taxonName) {
             $taxon = $this->getRepository('taxon')->findOneByName($taxonName);
             $channel->addTaxon($taxon);
         }
     }
 }