Sonata\Component\Basket\Basket::setCurrency PHP 메소드

setCurrency() 공개 메소드

public setCurrency ( Sonata\Component\Currency\CurrencyInterface $currency )
$currency Sonata\Component\Currency\CurrencyInterface
    public function setCurrency(CurrencyInterface $currency)
    {
        $this->currency = $currency;
    }

Usage Example

예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $currency = new Currency();
     $currency->setLabel('EUR');
     $basket = new Basket();
     $basket->setCurrency($currency);
     $basket->setProductPool($this->getProductPool());
     $nbCustomers = 100;
     $products = array($this->getReference('php_plush_blue_goodie_product'), $this->getReference('php_plush_green_goodie_product'), $this->getReference('travel_japan_small_product'), $this->getReference('travel_japan_medium_product'), $this->getReference('travel_japan_large_product'), $this->getReference('travel_japan_extra_large_product'), $this->getReference('travel_quebec_small_product'), $this->getReference('travel_quebec_medium_product'), $this->getReference('travel_quebec_large_product'), $this->getReference('travel_quebec_extra_large_product'), $this->getReference('travel_paris_small_product'), $this->getReference('travel_paris_medium_product'), $this->getReference('travel_paris_large_product'), $this->getReference('travel_paris_extra_large_product'), $this->getReference('travel_switzerland_small_product'), $this->getReference('travel_switzerland_medium_product'), $this->getReference('travel_switzerland_large_product'), $this->getReference('travel_switzerland_extra_large_product'));
     for ($i = 1; $i <= $nbCustomers; $i++) {
         $customer = $this->generateCustomer($manager, $i);
         $customerProducts = array();
         $orderProductsKeys = array_rand($products, rand(1, count($products)));
         if (is_array($orderProductsKeys)) {
             foreach ($orderProductsKeys as $orderProductKey) {
                 $customerProducts[] = $products[$orderProductKey];
             }
         } else {
             $customerProducts = array($products[$orderProductsKeys]);
         }
         $order = $this->createOrder($basket, $customer, $customerProducts, $manager, $i);
         $this->createTransaction($order, $manager);
         $this->createInvoice($order, $manager);
         if (!($i % 10)) {
             $manager->flush();
         }
     }
     $manager->flush();
 }
All Usage Examples Of Sonata\Component\Basket\Basket::setCurrency