Display Product name,Category and SKU on detail Page
HI, friends. Today I am going to discuss about how to display product name, category, sku and other product information on detail page in OpenCart. A opencart developer always require product information on detail page.One day i also faced this issue and i resolved out this problem. Therefore, I decided to share my code with all of you guys. Let us going to discuss in detail by how many approach we can product related information on detail page in opencart. Let us see below.
//to display product name
<?php $product_info = $this->model_catalog_product->getProduct($product_id); if ($product_info) { ?> <h2 style="font-size: 24px; font-weight: 700;"><?php echo $product_info['name']; ?></h2> <?php } ?>
<?php $categories = $this->model_catalog_product->getCategories($product_id); if ($categories) $categories_info = $this->model_catalog_category->getCategory($categories[0]['category_id']); $this->data['category_title'] = $categories_info['name']; ?>
This is to get the product’s first category title or heading (since a product may be in more than one category).
show SKU on product detail page
<?php $product_info = $this->model_catalog_product->getProduct($product_id); echo $product_info['sku']; ?>
alternate option
to get product name, product id and image
<?php echo $product_id; ?> //returns product id <?php echo $heading_title; ?> //returns product name <?php echo $popup; ?> //returns product image