@param Product $product
@param int     $quantity

@throws \Dumplie\SharedKernel\Domain\Exception\InvalidCurrencyException
@throws \Dumplie\Customer\Domain\Exception\ProductNotAvailableException
439676
public function add(Product $product, int $quantity)
    {
        if (!$product->isAvailable()) {
            throw new ProductNotAvailableException($product);
        }

        if (!$product->price()->hasCurrency($this->currency)) {
            throw new InvalidCurrencyException($this->currency, $product->price()->currency());
        }

        if (array_key_exists((string) $product->sku(), $this->items)) {
            $quantity += $this->items[(string) $product->sku()]->quantity();
        }

        $this->items[(string) $product->sku()] = new CartItem($product->sku(), $quantity);
    }
1167033
public function setProduct($product)
    {
        $this->id = $product->getId();
        $this->sku = $product->getSku();
        $this->name = $product->getName();

        $this->status = $this->statusFactory->create()
            ->getOptionText($product->getStatus());

        $options = $this->visibilityFactory->create()
            ->getOptionArray();
        $this->visibility = (string)$options[$product->getVisibility()];

        $this->getMinPrices($product);

        $this->url = $this->urlFinder->fetchFor($product);

        $this->imagePath = $this->mediaConfigFactory->create()
            ->getMediaUrl($product->getSmallImage());

        $this->stock = (float)number_format($this->getStockQty($product), 2, '.', '');

        $shortDescription = $product->getShortDescription();
        //limit short description
        if ($this->stringUtils->strlen($shortDescription) > \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT) {
            $shortDescription = mb_substr($shortDescription, 0, \Dotdigitalgroup\Email\Helper\Data::DM_FIELD_LIMIT);
        }

        $this->shortDescription = $shortDescription;

        //category data
        $count = 0;
        $categoryCollection = $product->getCategoryCollection()
            ->addNameToResult();
        foreach ($categoryCollection as $cat) {
            $this->categories[$count]['Id'] = $cat->getId();
            $this->categories[$count]['Name'] = $cat->getName();
            ++$count;
        }

        //website data
        $count = 0;
        $websiteIds = $product->getWebsiteIds();
        foreach ($websiteIds as $websiteId) {
            $website = $this->storeManager->getWebsite(
                $websiteId
            );
            $this->websites[$count]['Id'] = $website->getId();
            $this->websites[$count]['Name'] = $website->getName();
            ++$count;
        }

        $this->processProductOptions($product);

        unset(
            $this->itemFactory,
            $this->mediaConfigFactory,
            $this->visibilityFactory,
            $this->statusFactory,
            $this->helper,
            $this->storeManager
        );

        return $this;
    }
1312946
private function addProductVariantToOrder(ProductVariantInterface $productVariant, $quantity = 1)
    {
        $order = $this->sharedStorage->get('order');

        $this->addProductVariantsToOrderWithChannelPrice(
            $order,
            $this->sharedStorage->get('channel'),
            $productVariant,
            (int) $quantity
        );

        return $order;
    }
127176
public function createNewProductPriceForCurrency(
        ProductInterface $product,
        $priceValue,
        $minimumQuantity = 0.0,
        $currencyId = null
    ) {
        // Fetch currency.
        if (!$currencyId) {
            $currency = $this->currencyRepository->findByCode($this->defaultCurrency);
        } else {
            $currency = $this->currencyRepository->find($currencyId);
        }

        if (!$currency) {
            throw new ProductDependencyNotFoundException($this->currencyRepository->getClassName(), $currencyId);
        }

        $productPrice = new ProductPrice();
        $productPrice->setMinimumQuantity($minimumQuantity);
        $productPrice->setPrice($priceValue);
        $productPrice->setProduct($product);
        $productPrice->setCurrency($currency);
        $product->addPrice($productPrice);

        return $productPrice;
    }
659826
protected function prepareProduct(array &$product)
    {
        $options = array(
            'store_id' => $product['store_id'],
            'product_id' => $product['product_id']
        );

        $product['related'] = $this->product->getRelated($options);
        $product['price'] = $this->price->decimal($product['price'], $product['currency']);

        $this->setSkuCombinationProduct($product);
        $this->setItemAlias($product, 'product', $this->alias);
        $this->setItemImages($product, 'product', $this->image);
        $this->setItemTranslation($product, 'product', $this->translation_entity);

        if (!empty($product['images'])) {
            foreach ($product['images'] as &$file) {
                $this->setItemTranslation($file, 'file', $this->translation_entity);
            }
        }
    }
186754
public function add(Integer $quantity)
    {
        $amount = new Integer($this->getAmount()->toNative() + $quantity->toNative());
        $result = new self($amount, $this->getCurrency());

        return $result;
    }
979344
public function setInstallment($quantity, $value = null, $noInterestInstallmentQuantity = null)
    {
        $param = $quantity;
        if (isset($param) && is_array($param) || is_object($param)) {
            $this->setQuantity($param['quantity']);
            $this->setValue($param['value']);
            $this->setNoInterestInstallmentQuantity($param["noInterestInstallmentQuantity"]);
        } else {
            $this->setQuantity($quantity);
            $this->setValue($value);
            $this->setNoInterestInstallmentQuantity($noInterestInstallmentQuantity);
        }
    }
610737
public function newAction(Product $product, Request $request)
    {
        $restock = new RestockTransaction();
        $restock->setProduct($product);

        $form = $this->createForm(new RestockTransactionType(), $restock);

        if ($request->getMethod() == 'POST')
        {
            $form->bindRequest($request);

            if ($form->isValid())
            {
                try
                {
                    // For now, we always post the RestockTransaction, but
                    // later we'll check to see if this is a future transaction
                    $restock->post();

                    $em = $this->getDoctrine()->getEntityManager();
                    $em->persist($restock);
                    $em->flush();

                    return $this->redirect($this->generateUrl('Seller_product_show', array(
                        'id' => $product->getId(),
                    )));
                }
                catch (\Exception $e)
                {
                    // could not Restock Product
                }
            }
        }

        return $this->render('HarvestCloudCoreBundle:Seller/RestockTransaction:new.html.twig', array(
          'form'    => $form->createView(),
          'product' => $product,
        ));
    }
387480
@Override
    public void addProduct(IAtomContainer product, Double coefficient) {
        products.addAtomContainer(product, coefficient);
        /*
         * notifyChanged() is called by addReactant(Molecule reactant, double
         * coefficient)
         */
    }
1330245
public function load( $product ) {
		$this->product = $product;
		$this->setup_notification();
		$this->setup_actions();

		return $this;
	}
81909
public void setProduct(final String product) {
        if (product == null && this.product == null) {
            return;
        } else if (product == null) {
            removeChild(this.product);
            this.product = null;
        } else if (this.product == null) {
            this.product = new KeyValueNode<String>(CommonConstants.CS_PRODUCT_TITLE, product);
            appendChild(this.product, false);
        } else {
            this.product.setValue(product);
        }
    }
1150677
public function setProduct(ProductInterface $product)
    {
        $this->productId = $product->getId();
        $this->product = $product;
    }
465988
public function addProduct(Product $product)
    {
        if (count($this->products) > self::MAX_PRODUCT_COUNT) {
            throw new TooManyProducts(
                sprintf(
                    'Paytrail can only handle up to %d different products. Please group products using "amount".',
                    self::MAX_PRODUCT_COUNT
                )
            );
        }
        $this->products[] = $product;
    }
365064
private function createDeleteForm(Product $product)
    {
        return $this->createFormBuilder()
            ->setAction($this->generateUrl('ecommerce_product_delete', array('id' => $product->getId())))
            ->setMethod('DELETE')
            ->getForm()
        ;
    }
1344682
protected function isProductAvailable(string $deliveryDate, string $sku, int $quantity, string $warehouse): bool
    {
        $requestParameters = [
            ConditionalAvailabilityConstants::PARAMETER_WAREHOUSE => $warehouse,
            ConditionalAvailabilityConstants::PARAMETER_DATE => new DateTime($deliveryDate),
        ];

        $result = $this->conditionalAvailabilityClient->conditionalAvailabilitySkuSearch($sku, $requestParameters);

        foreach ($result->getResults() as $resultSet) {
            $data = $resultSet->getData();
            $dataQuantityInt = (int) $data['qty'];

            if ($dataQuantityInt >= $quantity) {
                return true;
            }
        }

        return false;
    }
187601
public function can_load( $product ) {
		if ( $this->is_from_partner( $product ) ) {
			return false;
		}
		if ( $product->is_theme() && ! current_user_can( 'switch_themes' ) ) {
			return false;
		}

		if ( $product->is_plugin() && ! current_user_can( 'install_plugins' ) ) {
			return false;
		}

		return true;
	}
773111
public function setQuantity($quantity) {
        if (!is_integer($quantity)) {
            throw new \Exception ("quantity must be an Integer");
        }
        if ($quantity < 0) {
            throw new \Exception ("quantity cannot be less than zero");
        }
        $this->quantity = $quantity;
    }