Creates and returns a pristine Product instance.

Prices are initialized to "zero amount" Money value objects,
using injected CurrencyWrapper default Currency

@return Product New Product entity
17934
public function create()
    {
        $zeroPrice = $this->createZeroAmountMoney();

        /**
         * @var Product $product
         */
        $classNamespace = $this->getEntityNamespace();
        $product = new $classNamespace();

        $stock = $this->useStock
            ? 0
            : ElcodiProductStock::INFINITE_STOCK;

        $product
            ->setStock($stock)
            ->setType(ElcodiProductTypes::TYPE_PRODUCT_PHYSICAL)
            ->setShowInHome(true)
            ->setPrice($zeroPrice)
            ->setReducedPrice($zeroPrice)
            ->setAttributes(new ArrayCollection())
            ->setVariants(new ArrayCollection())
            ->setCategories(new ArrayCollection())
            ->setImages(new ArrayCollection())
            ->setWidth(0)
            ->setHeight(0)
            ->setDepth(0)
            ->setWidth(0)
            ->setWeight(0)
            ->setImagesSort('')
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $product;
    }
873672
public function calculatePriceTax()
    {
        $money = new Money(0, new Currency($this->currency));

        $this->items->map(function ($item) use (&$money) {
            $money = $money->add($item->calculatePriceTax());
        });

        return $money;
    }
830053
public function create($adapterClass)
    {
        $adapter = new $adapterClass();
        $adapter->setDefaultCurrency($this->currencies['default']);
        $adapter->setManagedCurrencies($this->currencies['managed']);
        $adapter->setCurrencyClass($this->currencyClass);

        return $adapter;
    }
339652
public function newAction()
    {
        $form = $this->container->get('vespolina.product.form');

        return $this->container->get('templating')->renderResponse('VespolinaCommerceBundle:Product:new.html.'.$this->getEngine(), array(
            'form'                   => $form->createView(),
            'configuredOptionGroups' => $this->getConfiguredOptionsGroups(),
            'product'  => $this->container->get('vespolina.product_manager')->createProduct(),
       ));
    }
724624
public function negated() : Money
    {
        return new Money($this->amount->negated(), $this->currency, $this->context);
    }
366041
public function create()
    {
        /**
         * @var Currency $currency
         */
        $classNamespace = $this->getEntityNamespace();
        $currency = new $classNamespace();
        $currency
            ->setEnabled(true)
            ->setCreatedAt($this->now());

        return $currency;
    }
129072
public static function createFromGlobals()
    {
        $class = get_called_class();

        /** @var Request $request */
        $request = new $class($_GET, $_POST, array(), $_COOKIE, $_FILES, $_SERVER);

        $contentType = $request->server('CONTENT_TYPE', '');
        $requestMethod = $request->server('REQUEST_METHOD', 'GET');
        if (0 === strpos($contentType, 'application/x-www-form-urlencoded')
            && in_array(strtoupper($requestMethod), array('PUT', 'DELETE'))
        ) {
            parse_str($request->getContent(), $data);
            $request->request = $data;
        } elseif (0 === strpos($contentType, 'application/json')
            && in_array(strtoupper($requestMethod), array('POST', 'PUT', 'DELETE'))
        ) {
            $data = json_decode($request->getContent(), true);
            $request->request = $data;
        }

        return $request;
    }
650292
public static Balance zero(Currency currency) {

    return new Balance(
        currency,
        BigDecimal.ZERO,
        BigDecimal.ZERO,
        BigDecimal.ZERO,
        BigDecimal.ZERO,
        BigDecimal.ZERO,
        BigDecimal.ZERO,
        BigDecimal.ZERO);
  }
910562
public function create()
    {
        /**
         * @var CartLine $cartLine
         */
        $classNamespace = $this->getEntityNamespace();
        $cartLine = new $classNamespace();
        $cartLine
            ->setAmount($this->createZeroAmountMoney())
            ->setPurchasableAmount($this->createZeroAmountMoney());

        return $cartLine;
    }
1365080
protected function createShopObject()
    {
        $objectName = $this->getShopObjectName();
        if ($objectName) {
            $shopObject = oxNew($objectName, 'core');
            if ($shopObject instanceof \OxidEsales\Eshop\Core\Model\MultiLanguageModel) {
                $shopObject->setLanguage(0);
                $shopObject->setEnableMultilang(false);
            }
        } else {
            $shopObject = oxNew('oxBase', 'core');
            $shopObject->init($this->getBaseTableName());
        }

        return $shopObject;
    }
435816
public function getActShopCurrencyObject()
    {
        if ($this->_oActCurrencyObject === null) {
            $cur = $this->getShopCurrency();
            $currencies = $this->getCurrencyArray();
            if (!isset($currencies[$cur])) {
                $this->_oActCurrencyObject = reset($currencies); // reset() returns the first element
            } else {
                $this->_oActCurrencyObject = $currencies[$cur];
            }
        }

        return $this->_oActCurrencyObject;
    }
296334
protected function buildCurrencyField()
    {
        $name = $this->getName();

        // Validate allowed currencies
        $currencyValue = $this->fieldCurrency ? $this->fieldCurrency->dataValue() : null;
        $allowedCurrencies = $this->getAllowedCurrencies();
        if (count($allowedCurrencies) === 1) {
            // Hidden field for single currency
            $field = HiddenField::create("{$name}[Currency]");
            reset($allowedCurrencies);
            $currencyValue = key($allowedCurrencies);
        } elseif ($allowedCurrencies) {
            // Dropdown field for multiple currencies
            $field = DropdownField::create(
                "{$name}[Currency]",
                _t('SilverStripe\\Forms\\MoneyField.FIELDLABELCURRENCY', 'Currency'),
                $allowedCurrencies
            );
        } else {
            // Free-text entry for currency value
            $field = TextField::create(
                "{$name}[Currency]",
                _t('SilverStripe\\Forms\\MoneyField.FIELDLABELCURRENCY', 'Currency')
            );
        }

        $field->setReadonly($this->isReadonly());
        $field->setDisabled($this->isDisabled());
        if ($currencyValue) {
            $field->setValue($currencyValue);
        }
        $this->fieldCurrency = $field;
        return $field;
    }
455011
public TypeSpec createCurrencyUtil(String className, Map<String, CurrencyData> currencies) {
    TypeSpec.Builder type = TypeSpec.classBuilder(className)
        .addModifiers(Modifier.PUBLIC);
    
    CurrencyData defaultData = currencies.get("DEFAULT");
    currencies.remove("DEFAULT");
    
    MethodSpec.Builder code = MethodSpec.methodBuilder("getCurrencyDigits")
        .addModifiers(PUBLIC, STATIC)
        .addParameter(Types.CLDR_CURRENCY_ENUM, "code")
        .returns(int.class);
    
    code.beginControlFlow("switch (code)");
    for (Map.Entry<String, CurrencyData> entry : currencies.entrySet()) {
      CurrencyData data = entry.getValue();
      code.addStatement("case $L: return $L", entry.getKey(), data.digits);
    }
    code.addStatement("default: return $L", defaultData.digits);
    code.endControlFlow();
    
    type.addMethod(code.build());
    return type.build();
  }
1326933
public function create()
    {
        $instance = self::createTableRateShipping($this);
        $this->setId($instance->getId());
        return $instance;
    }
279509
public function createContent() {
    // Creates a dummy $10 flat rate shipping method.
    $method = ShippingMethod::create([
      'name' => t('Flat rate'),
      'plugin' => [
        'target_plugin_id' => 'flat_rate',
        'target_plugin_configuration' => [
          'rate_label' => t('Flat rate'),
          'rate_amount' => [
            'number' => 10,
            'currency_code' => 'AUD',
          ],
          'default_package_type' => 'custom_box',
        ],
      ],
    ]);

    $storeId = $this->loadStoreId();
    if ($storeId !== NULL) {
      $method->setStoreIds([$storeId]);
    }

    $method->save();

    // Set default shipment type on order type.
    /** @var \Drupal\commerce_order\Entity\OrderTypeInterface $orderType */
    $orderType = $this->getDefaultOrderType();
    $orderType->setThirdPartySetting(
      'commerce_shipping',
      'shipment_type',
      'default'
    );
    $orderType->save();
  }
474158
public function product(Product $product): Money
    {
        if ($product->quantity >= $this->quantity) {
            return $this->rate->product($product);
        }

        return new Money(0, $product->price->getCurrency());
    }
752638
public static MonetaryAmountDecimalFormatBuilder newInstance() {
        MonetaryAmountDecimalFormatBuilder builder = new MonetaryAmountDecimalFormatBuilder();
        builder.decimalFormat = (DecimalFormat) NumberFormat.getCurrencyInstance();
        return builder;
    }