@param \Magento\Catalog\Model\Product $product

@return $this
197914
public function setPrice($product)
    {
        $this->price = (float)number_format($product->getFinalPrice(), 2, '.', '');
        $total = $this->price * $this->qty;

        $this->totalValueOfProduct = (float)number_format($total, 2, '.', '');

        return $this;
    }
251215
public function addProductVariant(ProductVariant $productVariant)
    {
        $this->productVariants->add($productVariant);

        $this->setOwningSideRelation($productVariant);

        return $this;
    }
953657
public function load( $product ) {
		$this->product = $product;
		add_action( 'admin_head', array( $this, 'load_resources' ) );
		add_action( 'wp_ajax_' . $this->product->get_key() . '_uninstall_feedback', array( $this, 'post_deactivate' ) );

		return $this;
	}
909668
public function copyAction(Product $product)
    {


        $productCopy = new Product();
        $copyName = $this->get('translator')->trans('Copy of') . " " . $product->getName();
        $productCopy->setName($copyName);

        $productCopy->setCostPrice($product->getCostPrice());
        $productCopy->setDescription($product->getDescription()??$copyName);
        $productCopy->setCode($product->getCode());
        $productCopy->setImage($product->getImage());
        $productCopy->setPlace($product->getPlace());
        $productCopy->setSalePrice($product->getSalePrice());
        $productCopy->setSupplier($product->getSupplier());
        $productCopy->setWarehouse($product->getWarehouse());

        // boleans
        $productCopy->setEnabled($product->getEnabled());
        $productCopy->setForSale($product->getForSale());
        $productCopy->setCompositionOnDemand($product->isCompositionOnDemand());
        $productCopy->setPack($product->isPack());
        $productCopy->setManualPackPricing($product->isManualPackPricing());
        $productCopy->setRawMaterial($product->getRawMaterial());

        $em = $this->getDoctrine()->getManager();
        $em->persist($productCopy);

        // relations

        /* @var ProductRawMaterial $rawMaterial */
        foreach ($product->getRawMaterials() as $rawMaterial) {
            $rawMaterialCopy = new ProductRawMaterial();
            $rawMaterialCopy->setRawMaterial($rawMaterial->getRawMaterial());
            $rawMaterialCopy->setProduct($productCopy);
            $rawMaterialCopy->setMeasureUnit($rawMaterial->getMeasureUnit());
            $rawMaterialCopy->setQuantity($rawMaterial->getQuantity());

            $em->persist($rawMaterialCopy);

            $productCopy->addRawMaterial($rawMaterialCopy);

        }

        /* @var ProductCategory $category */
        foreach ($product->getCategories() as $category) {
            $productCopy->addCategory($category);
        }

        /* @var ProductCustomField $customField */
        foreach ($product->getCustomFields() as $customField) {
            $customFieldCopy = new ProductCustomField();
            $customFieldCopy->setProduct($productCopy);
            $customFieldCopy->setSettingField($customField->getSettingField());
            $customFieldCopy->setValue($customField->getValue());

            $em->persist($customFieldCopy);

            $productCopy->addCustomField($customFieldCopy);
        }

        $em->flush();


        return $this->redirect($this->generateUrl('product_show', array("id" => $productCopy->getId())));
    }
474158
public function product(Product $product): Money
    {
        if ($product->quantity >= $this->quantity) {
            return $this->rate->product($product);
        }

        return new Money(0, $product->price->getCurrency());
    }
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);
    }
418515
public function setProducts($product)
    {
        if (is_string($product)) {
            $product = [$product];
        }

        if (!is_array($product)) {
            throw new \InvalidArgumentException("The product list must be an string or an array, given " . gettype($product));
        }

        $this->products = $product;
    }
217421
public function editAction(Request $request, Product $product)
    {
        //access control
        $user = $this->container->get('security.token_storage')->getToken()->getUser();  
        if ($user->isGranted('ROLE_USER') && $product->getActor()->getId() != $user->getId()) {
            return $this->redirect($this->generateUrl('ecommerce_product_index'));
        }
       
        $formConfig = array();
        if ($user->isGranted('ROLE_USER')) { $formConfig['actor'] = $user; }
        $deleteForm = $this->createDeleteForm($product);

        $editForm = $this->createForm('EcommerceBundle\Form\ProductType', $product, $formConfig);
        $attributesForm = $this->createForm('EcommerceBundle\Form\ProductAttributesType', $product, array('category' => $product->getCategory()->getId()));
        $featuresForm = $this->createForm('EcommerceBundle\Form\ProductFeaturesType', $product, array('category' => $product->getCategory()->getId()));
        $relatedProductsForm = $this->createForm('EcommerceBundle\Form\ProductRelatedType', $product);

        if($request->getMethod('POST')){
            $redirectParams = array('id' => $product->getId());

            if ($request->request->has('product_attributes')) {
                // attributes were submitted
                $editForm = $attributesForm;
                $redirectParams = array_merge($redirectParams, array('attributes' => 1));
            } else if ($request->request->has('product_features')) {
                // features were submitted
                $editForm = $featuresForm;
                $redirectParams = array_merge($redirectParams, array('features' => 1));
            } else if ($request->request->has('product_related')) {
                // related products were submitted
                $editForm = $relatedProductsForm;
                $redirectParams = array_merge($redirectParams, array('related' => 1));
            }
            $editForm->handleRequest($request);

            if ($editForm->isSubmitted() && $editForm->isValid()) {
                $em = $this->getDoctrine()->getManager();
                $em->persist($product);
                $em->flush();

                $this->get('session')->getFlashBag()->add('success', 'product.edited');
                
                return $this->redirectToRoute('ecommerce_product_show', $redirectParams);
            }
        }
        
        return array(
            'entity'          => $product,
            'edit_form'       => $editForm->createView(),
            'attributes_form' => $attributesForm->createView(),
            'features_form'   => $featuresForm->createView(),
            'related_form'    => $relatedProductsForm->createView(),
            'delete_form'     => $deleteForm->createView(),
        );
    }
864947
protected function prepareProduct(array &$product)
    {
        $selected = $this->getSelectedCombinationProduct($product);
        $this->unshiftSelectedImageProduct($selected, $product);

        $this->setItemImages($product, 'product', $this->image);
        $this->setItemThumbProduct($product, $this->image);
        $this->setItemProductInComparison($product, $this->product_compare);
        $this->setItemProductBundle($product, $this->product, $this->image);
        $this->setItemProductInWishlist($product, $this->wishlist);

        $this->setItemPriceCalculated($selected, $this->product);
        $this->setItemPriceFormatted($selected, $this->price, $this->current_currency);

        $product['selected_combination'] = $selected;
        $product['total_reviews'] = $this->getTotalReviewsProduct($product);

        $this->setItemProductFields($product, $this->image, $this->product_class);
    }
1097177
public function setCommerceProductId(int $nb_commerce_product_id) : CNabuDataObject
    {
        if ($nb_commerce_product_id === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$nb_commerce_product_id")
            );
        }
        $this->setValue('nb_commerce_product_id', $nb_commerce_product_id);
        
        return $this;
    }
711613
def product(self, *products):
        
        """
        for product in products:
            self._product.append(product)
        return self
1309578
protected function updateProduct()
    {
        $this->controlAccess('product_edit');

        if ($this->product->update($this->data_product['product_id'], $this->getSubmitted())) {
            $this->redirect('admin/content/product', $this->text('Product has been updated'), 'success');
        }

        $this->redirect('', $this->text('Product has not been updated'), 'warning');
    }
1285727
public function product( $prodIds )
	{
		if( !empty( $prodIds ) && ( $ids = array_unique( $this->validateIds( (array) $prodIds ) ) ) !== [] ) {
			$this->conditions[] = $this->filter->compare( '==', 'product.id', $ids );
		}

		return $this;
	}
700591
public function setProduct(\Amulen\ShopBundle\Entity\Product $product = null)
    {
        $this->product = $product;

        return $this;
    }
546987
public function destroy(Product $product)
    {
        $this->product->destroy($product);

        return redirect()->route('admin.product.product.index')
            ->withSuccess(trans('core::core.messages.resource deleted', ['name' => trans('product::products.title.products')]));
    }
168209
public function indexProduct($product_id)
    {
        $this->setProduct($product_id);
        $this->setMetaIndexProduct();
        $this->setTitleIndexProduct();
        $this->setBreadcrumbIndexProduct();
        $this->setHtmlFilterIndexProduct();

        $this->setData('product', $this->data_product);

        $this->setDataSummaryIndexProduct();
        $this->setDataImagesIndexProduct();
        $this->setDataCartFormIndexProduct();
        $this->setDataRatingWidgetIndexProduct();

        $this->setDataDescriptionIndexProduct();
        $this->setDataAttributesIndexProduct();
        $this->setDataReviewsIndexProduct();
        $this->setDataRecentIndexProduct();
        $this->setDataRelatedIndexProduct();
        $this->setDataBundledIndexProduct();

        $this->setJsIndexProduct();
        $this->outputIndexProduct();
    }
1057519
public function addProduct($product = array())
    {
        if (!is_array($product)) {
            $this->errorMessage[] = 'PRODUCT: Not a valid product!';
        }
        foreach ($this->productFields as $field) {
            if (array_key_exists($field, $product)) {
                $add[$field] = $this->cleanString($product[$field]);
            } elseif (!array_key_exists($field, $product)) {
                $add[$field] = ' ';
                $this->debugMessage[] = 'Missing product field: ' . $field;
            }
        }
        $this->products[] = $add;
    }