Displays the product page
@param integer $product_id
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();
    }
928509
public function listProduct()
    {
        $this->actionListProduct();
        $this->setTitleListProduct();
        $this->setBreadcrumbListProduct();
        $this->setFilterListProduct();
        $this->setPagerListProduct();

        $this->setData('products', $this->getListProduct());
        $this->setData('currencies', $this->currency->getList(array('enabled' => true)));

        $this->outputListProduct();
    }
82184
public function getByProductIds(array $productIds, $storeId)
    {
        $searchQueryTable = $this->getTable('search_query');
        $select = $this->getBaseSelect()
            ->joinInner($searchQueryTable, "main_table.query_id = {$searchQueryTable}.query_id", [])
            ->where('product_id IN(?)', $productIds)
            ->where('store_id = ?', $storeId)
            ->columns(['product_id', 'query_id', 'position', 'is_blacklisted']);

        return $this->getConnection()->fetchAll($select);
    }
648626
public function show($id)
    {
        $options = $this->getParams('includes');

        $product = Subbly::api('subbly.product')->find($id, $options);

        return $this->jsonResponse(array(
            'product' => $this->presenter->single($product),
        ));
    }
995845
public function delete($product_id, $check = true)
    {
        $result = null;
        $this->hook->attach('product.delete.before', $product_id, $check, $result, $this);

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

        if ($check && !$this->canDelete($product_id)) {
            return false;
        }

        $result = (bool) $this->db->delete('product', array('product_id' => $product_id));

        if ($result) {
            $this->deleteLinked($product_id);
        }

        $this->hook->attach('product.delete.after', $product_id, $check, $result, $this);
        return (bool) $result;
    }
755940
public function getFields($product_class_id)
    {
        $result = &gplcart_static("product.class.fields.$product_class_id");

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

        $result = array();
        $fields = $this->field->getList();

        $ops = array(
            'product_class_id' => $product_class_id
        );

        foreach ((array) $this->product_class_field->getList($ops) as $product_class_field) {
            if (isset($fields[$product_class_field['field_id']])) {

                $data = array('values' => $this->field_value->getList(array(
                    'field_id' => $product_class_field['field_id'])));

                $data += $fields[$product_class_field['field_id']];
                $data += $product_class_field;

                $result[$fields[$product_class_field['field_id']]['type']][$product_class_field['field_id']] = $data;
            }
        }

        return $result;
    }
696710
public function getQrcPayUrl($product_id)
    {
        $data = array(
            'appid'      => $this->appid,
            'mch_id'     => $this->mch_id,
            'time_stamp' => (string)time(),
            'nonce_str'  => Tools::createNoncestr(),
            'product_id' => (string)$product_id,
        );
        $data['sign'] = Tools::getPaySign($data, $this->partnerKey);
        return "weixin://wxpay/bizpayurl?" . http_build_query($data);
    }
1101320
public function updateAttributesAndFeaturesAction($productId)
    {
        $product = ProductQuery::create()->findPk($productId);

        if ($product != null) {
            $featureTemplate = FeatureTemplateQuery::create()->filterByTemplateId($product->getTemplateId())->find();

            if ($featureTemplate !== null) {
                // Get all features for the template attached to this product
                $allFeatures = FeatureQuery::create()
                    ->filterByFeatureTemplate($featureTemplate)
                    ->find();

                $updatedFeatures = array();

                // Update all features values, starting with feature av. values
                $featureValues = $this->getRequest()->get('feature_value', array());

                foreach ($featureValues as $featureId => $featureValueList) {
                    // Delete all features av. for this feature.
                    $event = new FeatureProductDeleteEvent($productId, $featureId);

                    $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);

                    // Add then all selected values
                    foreach ($featureValueList as $featureValue) {
                        $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue);

                        $this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event);
                    }

                    $updatedFeatures[] = $featureId;
                }

                // Update then features text values
                $featureTextValues = $this->getRequest()->get('feature_text_value', array());

                foreach ($featureTextValues as $featureId => $featureValue) {
                    // Check if a FeatureProduct exists for this product and this feature (for another lang)
                    $freeTextFeatureProduct = FeatureProductQuery::create()
                        ->filterByProductId($productId)
                        ->filterByIsFreeText(true)
                        ->findOneByFeatureId($featureId);

                    // If no corresponding FeatureProduct exists AND if the feature_text_value is empty, do nothing
                    if (\is_null($freeTextFeatureProduct) && empty($featureValue)) {
                        continue;
                    }

                    $event = new FeatureProductUpdateEvent($productId, $featureId, $featureValue, true);
                    $event->setLocale($this->getCurrentEditionLocale());

                    $this->dispatch(TheliaEvents::PRODUCT_FEATURE_UPDATE_VALUE, $event);

                    $updatedFeatures[] = $featureId;
                }

                // Delete features which don't have any values
                /** @var Feature $feature */
                foreach ($allFeatures as $feature) {
                    if (! \in_array($feature->getId(), $updatedFeatures)) {
                        $event = new FeatureProductDeleteEvent($productId, $feature->getId());

                        $this->dispatch(TheliaEvents::PRODUCT_FEATURE_DELETE_VALUE, $event);
                    }
                }
            }
        }

        // If we have to stay on the same page, do not redirect to the successUrl,
        // just redirect to the edit page again.
        if ($this->getRequest()->get('save_mode') == 'stay') {
            return $this->redirectToEditionTemplate();
        }

        // Redirect to the category/product list
        return $this->redirectToListTemplate();
    }
748503
public function deleteImage($productId)
    {
        $productId = (int) $productId;

        if ($productId == 0 || $productId == '') {
            $message = 'Product ID not correct: ' . $productId;
            $this->log($message);
            die(json_encode([
                'status' => 0,
                'msg' => $message
            ]));
        }

        $product = $this->Product->find('all', [
            'conditions' => [
                'Products.id_product' => $productId
            ],
            'contain' => [
                'Images',
                'Manufacturers'
            ]
        ])->first();
        
        $this->Product->changeImage(
            [
                [$productId => 'no-image']
            ]
        );

        $actionLogMessage = __d('admin', 'Image_ID_{0}_from_manufacturer_{1}_was_deleted_successfully_Product_{1}_Manufacturer_{2}.', [
            $product->image->id_image,
            '<b>' . $product->name . '</b>',
            '<b>' . $product->manufacturer->name . '</b>'
        ]);

        $this->Flash->success($actionLogMessage);
        $this->ActionLog->customSave('product_image_deleted', $this->AppAuth->getUserId(), $productId, 'products', $actionLogMessage);

        $this->getRequest()->getSession()->write('highlightedRowId', $productId);

        $this->redirect($this->referer());
    }
981178
public function show(Product $product)
    {
        $product->load('group', 'category');

        //increasing product counters, in order to have a suggestion orden
        (new ProductsRepository)->increment('view_counts', $product);

        //saving the product tags into users preferences
        if (trim($product->tags) != '' && auth()->check()) {
            auth()->user()->updatePreferences('product_viewed', $product->tags);
        }

        return view('products.detailProd', [
            'suggestions' => Suggestions\Suggest::for('product_viewed')->shake()->get('product_viewed'),
            'reviews' => OrderDetail::ReviewsFor($product->id),
            'allWishes' => Order::forSignedUser('wishlist'),
            'features' => Feature::filterable()->get(),
            'product' => $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);
    }
947440
public function setProductId( $productid )
	{
		if ( $productid == $this->getProductId() ) { return; }

		$this->_values['ordprodid'] = (int) $productid;
		$this->setModified();
	}
299615
private function addRecommendedProducts(
        &$productsToDisplayCounter,
        $limit,
        $maxPerChild,
        $recommendedProducts,
        &$productsToDisplay,
        &$product
    ) {
        $i = 0;

        foreach ($recommendedProducts as $product) {
            //check if still exists
            if ($product->getId() && $productsToDisplayCounter < $limit
                && $i <= $maxPerChild
                && $product->isSaleable()
                && !$product->getParentId()
            ) {
                //we have a product to display
                $productsToDisplay[$product->getId()] = $product;
                $i++;
                $productsToDisplayCounter++;
            }
        }
    }
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();
    }
1191942
public function getProductRatingById($productId)
    {
        $this->validateProductId($productId);

        $queryBuilder = $this->queryBuilderFactory->create();
        $queryBuilder
            ->select([
                'OXID',
                'OXRATING',
                'OXRATINGCNT'
            ])
            ->from('oxarticles')
            ->where('oxid = :productId')
            ->setMaxResults(1)
            ->setParameter('productId', $productId);

        return $this->mapper->map(
            new ProductRating(),
            $queryBuilder->execute()->fetch()
        );
    }
10891
public function showCustomer($customer_id)
    {
        $response = $this->client->get('customers/' . $customer_id);
        return json_decode($response->getBody())->customer;
    }
1314428
public function display($replicator_id)
    {
        $widget = $this->getClonedWidget($replicator_id);
        // substitute the replicator_id into the content block's contents
        $widget->content = str_replace('%s', $replicator_id, $widget->content);
        $widget->display();
    }