Set a product data
@param integer $product_id
356101
protected function setProduct($product_id)
    {
        $this->data_product = array();

        if (is_numeric($product_id)) {

            $conditions = array(
                'language' => 'und',
                'product_id' => $product_id
            );

            $this->data_product = $this->product->get($conditions);

            if (empty($this->data_product)) {
                $this->outputHttpStatus(404);
            }

            $this->prepareProduct($this->data_product);
        }
    }
13984
protected function setDataRelatedIndexProduct()
    {
        $products = $this->getRelatedProduct();

        if (!empty($products)) {

            $pager_options = array(
                'key' => 'rlp',
                'total' => count($products),
                'limit' => $this->config('related_pager_limit', 4)
            );

            $pager = $this->getPager($pager_options);

            if (!empty($pager['limit'])) {
                list($from, $to) = $pager['limit'];
                $products = array_slice($products, $from, $to);
            }

            $data = array(
                'products' => $products,
                'pager' => $pager['rendered']
            );

            $this->setData('related', $this->render('product/related', $data));
        }
    }
860668
public function editReview($product_id, $review_id = null)
    {
        $this->setProductReview($product_id);
        $this->setReview($review_id);
        $this->setTitleEditReview();
        $this->setBreadcrumbEditReview();

        $this->setData('review', $this->data_review);
        $this->setData('product', $this->data_product);
        $this->setData('can_delete', $this->canDeleteReview());

        $this->submitEditReview();
        $this->setDataRatingEditReview();
        $this->outputEditReview();
    }
1218313
public function putAction(Request $request, $productId)
    {
        $locale = $request->get('locale');
        $parameters = $request->request->all();

        $product = $this->fetchProduct($productId);

        $content = $this->getProductContentMapper()->map($product, $parameters, $locale);
        $this->getEntityManager()->flush();

        $view = $this->view($content, Response::HTTP_OK);

        return $this->handleView($view);
    }
299953
protected function setDataCartFormIndexProduct()
    {
        $data = array(
            'product' => $this->data_product,
            'share' => $this->getWidgetShare()
        );

        $this->setData('cart_form', $this->render('cart/add', $data, true));
    }
436019
public function getByProduct($product_id)
    {
        $result = null;
        $this->hook->attach('rating.get.before', $product_id, $result, $this);

        if (isset($result)) {
            return $result;
        }

        $sql = 'SELECT rating, votes FROM rating WHERE product_id=?';
        $result = $this->db->fetch($sql, array($product_id));

        $this->hook->attach('rating.get.after', $product_id, $result, $this);
        return $result;
    }
944509
public function editProductClass($product_class_id = null)
    {
        $this->setProductClass($product_class_id);
        $this->setTitleEditProductClass();
        $this->setBreadcrumbEditProductClass();

        $this->setData('can_delete', $this->canDeleteProductClass());
        $this->setData('product_class', $this->data_product_class);

        $this->submitEditProductClass();
        $this->outputEditProductClass();
    }
651678
protected function setDataRatingWidgetIndexProduct()
    {
        $data = array(
            'product' => $this->data_product,
            'rating' => $this->rating->getByProduct($this->data_product['product_id'])
        );

        $this->setData('rating', $this->render('common/rating/static', $data));
    }
1362186
public function setProductTemplateAction($productId)
    {
        // Check current user authorization
        if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) {
            return $response;
        }

        $product = ProductQuery::create()->findPk($productId);

        if ($product != null) {
            $template_id = \intval($this->getRequest()->get('template_id', 0));

            $this->dispatch(
                TheliaEvents::PRODUCT_SET_TEMPLATE,
                new ProductSetTemplateEvent($product, $template_id, $this->getCurrentEditionCurrency()->getId())
            );
        }

        return $this->redirectToEditionTemplate();
    }
333042
public function delete($product_id, array $options = array())
    {
        $result = null;
        $this->hook->attach('sku.delete.before', $product_id, $options, $result, $this);

        if (isset($result)) {
            return (bool) $result;
        }

        $sql = 'DELETE FROM product_sku WHERE product_id=?';

        if (!empty($options['combinations'])) {
            $sql .= ' AND LENGTH(combination_id) > 0';
        }

        if (!empty($options['base'])) {
            $sql .= ' AND LENGTH(combination_id) = 0';
        }

        $result = (bool) $this->db->run($sql, array($product_id))->rowCount();
        $this->hook->attach('sku.delete.after', $product_id, $options, $result, $this);
        return (bool) $result;
    }
996620
protected function setFieldFieldValue($field_id)
    {
        $this->data_field = $this->field->get($field_id);

        if (empty($this->data_field)) {
            $this->outputHttpStatus(404);
        }
    }
947440
public function setProductId( $productid )
	{
		if ( $productid == $this->getProductId() ) { return; }

		$this->_values['ordprodid'] = (int) $productid;
		$this->setModified();
	}
1002701
protected function setStateCity($state_id)
    {
        $this->data_state = $this->state->get($state_id);

        if (empty($this->data_state)) {
            $this->outputHttpStatus(404);
        }
    }
258928
protected function updateProductClassField($product_class_field_id)
    {
        if (!$this->isError() && !$this->product_class_field->update($product_class_field_id, $this->getSubmitted())) {
            $this->errorAndExit($this->text('Unexpected result'));
        }
    }
400318
public function editProductClassField($product_class_id)
    {
        $this->setProductClassProductClassField($product_class_id);
        $this->setTitleEditProductClassField();
        $this->setBreadcrumbEditProductClassField();

        $this->setData('product_class', $this->data_product_class);
        $this->setData('fields', $this->getUniqueListProductClassField());

        $this->submitEditProductClassField();
        $this->outputEditProductClassField();
    }
812236
protected function setProductReview($product_id)
    {
        $this->data_product = $this->product->get($product_id);

        if (empty($this->data_product['status']) || $this->data_product['store_id'] != $this->store_id) {
            $this->outputHttpStatus(404);
        }

        $this->prepareProductReview($this->data_product);
    }
250578
public function canDelete($product_class_id)
    {
        $sql = 'SELECT product_id FROM product WHERE product_class_id=?';
        $result = $this->db->fetchColumn($sql, array($product_class_id));
        return empty($result);
    }