Fetches product from db. If not found an exception is thrown.

@param int $productId

@throws ProductNotFoundException

@return ProductInterface
763534
private function retrieveProductById($productId)
    {
        // Fetch product.
        $product = $this->productRepository->find($productId);
        if (!$product) {
            throw new ProductNotFoundException($productId);
        }

        return $product;
    }
1153477
public function newAction($featureId)
    {
        $em = $this->getDoctrine()->getManager();

        /** @var Feature $feature */
        $feature = $em->getRepository('EcommerceBundle:Feature')->find($featureId);

        if (!$feature) {
            throw $this->createNotFoundException('Unable to find Feature entity.');
        }

        $entity = new FeatureValue();
        $form   = $this->createForm(new FeatureValueType(), $entity);

        return array(
            'entity'      => $entity,
            'feature'   => $feature,
            'form'        => $form->createView(),
        );
    }
1160945
public function putAction(Request $request, $productId)
    {
        $mediaIds = $request->get('mediaIds');

        if (null === $mediaIds || !is_array($mediaIds)) {
            throw new ProductException('No media ids given.');
        }

        /** @var Product $product */
        $product = $this->getProductRepository()->find($productId);
        if (!$product) {
            throw new EntityNotFoundException($this->getProductEntityName(), $productId);
        }

        $this->getProductMediaManager()->save($product, $mediaIds);
        $this->getEntityManager()->flush();

        $view = $this->view(null, Response::HTTP_NO_CONTENT);

        return $this->handleView($view);
    }
1038939
public function get($serviceId)
    {
        if (!$this->has($serviceId)) {
            throw NotFoundException::constructWithThingNotFound($serviceId);
        }
        return $this->symfonyServiceContainer->get($serviceId);
    }
1274095
public function getProduct($productId)
    {
        $result = $this->httpRaw(self::WECHAT_SHOP_PRODUCT_GET_URL . 'access_token=' . $this->getAccessToken(), [
            'product_id' => $productId
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'success' ? $result['product_info'] : false;
    }
248318
protected function getCategoryProductSelect($productIds, $storeId)
    {
        $select = $this->getConnection()->select()
            ->from(['cpi' => $this->getTable($this->getCategoryProductIndexTable($storeId))])
            ->where('cpi.store_id = ?', $storeId)
            ->where('cpi.product_id IN(?)', $productIds);

        return $select;
    }
298248
public function findOne($productId)
    {
        $this->useAlternateEndpoint = true;
        $this->queryParams['ProductIds'] = $productId;
        $this->addAllProductImages();
        $this->addAllShopLogos();
        $response = $this->send();
        $products = $response->getProducts();
        if (isset($products[0])) {
            return $products[0];
        }

        return null;
    }
455326
public function actionShow(int $id)
    {

        $this->trigger(self::EVENT_BEFORE_SHOW, $this->getViewedProductEvent($id));

        $product = Product::find()
            ->where(['show' => true, 'id' => $id, 'status' => Product::STATUS_SUCCESS])
            ->one();

        if (!empty($product)) {

            $this->setSeoData($product);

            $this->trigger(self::EVENT_AFTER_SHOW);

            return $this->render('show', [
                'product' => $product,
                'cart' => new CartForm(),
                'defaultCombination' => Combination::find()->where([
                    'product_id' => $id,
                    'default' => true
                ])->one()
            ]);
        } else throw new NotFoundHttpException();
    }
121647
public function getById(OrderId $orderId) : Order
    {
        if (!array_key_exists((string)$orderId, $this->orders)) {
            throw OrderNotFoundException::byId($orderId);
        }

        return $this->orders[(string)$orderId];
    }
589053
protected function findProductModelById(string $id): ?ProductInterface
    {
        /**
         * @var ProductInterface
         */
        $class = $this->modelBuilder->getInterfaceClass($this->config, ProductInterface::class);

        return $class::findProductBy1c($id);
    }
1015725
private function getProduct($productId)
    {
        if (! isset($this->products[$productId])) {
            $product = $this->productFactory->create()
                ->setStoreId($this->model->getStoreId());
            $this->productResource->load($product, $productId);
            $this->products[$productId] = $product;
        }

        return $this->products[$productId];
    }
947440
public function setProductId( $productid )
	{
		if ( $productid == $this->getProductId() ) { return; }

		$this->_values['ordprodid'] = (int) $productid;
		$this->setModified();
	}
674331
public function setStatusForProduct(ProductInterface $product, $statusId)
    {
        // Check if status has changed.
        if ($product->getStatus() && $product->getStatus()->getId() === $statusId) {
            return;
        }

        $status = $this->statusRepository->find($statusId);
        if (!$status) {
            throw new ProductDependencyNotFoundException(self::$productStatusEntityName, $statusId);
        }

        // Set new status to product.
        $product->setStatus($status);

        // If product has variants, set status for all variants as well.
        if ($product->getType()
            && $product->getType()->getId() === (int) $this->productTypesMap['PRODUCT_WITH_VARIANTS']
        ) {
            $variants = $this->productRepository->findByParent($product);
            foreach ($variants as $variant) {
                $variant->setStatus($status);
            }
        }
    }
788493
public Observable<Product> getProduct(int productId) {
    return getAllProducts().flatMap(products -> Observable.fromIterable(products))
        .filter(product -> product.getId() == productId)
        .take(1);
  }
68617
public function getProduct($id, $combinationId = null)
    {
        $product = null;

        if ($this->isContainsProduct($id, $combinationId)) {
            $product = Product::findOne($id);
        };

        return $product;
    }
277249
public function getBySku(SKU $sku) : Product
    {
        if (!array_key_exists((string) $sku, $this->products)) {
            throw ProductNotFoundException::bySku($sku);
        }

        return $this->products[(string) $sku];
    }
693151
public function getProductCode(ProductInterface $product)
    {
        foreach ($this->products as $code => $productDescription) {
            $className = $productDescription->getManager()->getClass();
            if ($product instanceof $className) {
                return $code;
            }
        }
    }