Post by Cyto » Fri Jan 15, 2016 9:49 pm

Is there a way to get a product data of a ID into a template?
I tried to create a custom php function inside featured controller, but I kept getting function not found in template featured.

Code I used:

Code: Select all

	
	public function getProductById($product_id) {
		$this->load->model('catalog/product');
		$product_info = $this->model_catalog_product->getProduct($product_id);
		return $product_info;
	}
Perhaps there is an another way or what am I doing wrong?

Newbie

Posts

Joined
Fri Oct 17, 2014 8:30 pm

Post by opencartboost » Sat Jan 16, 2016 8:50 pm

Why do you create new function to get product ID?
Every product array contain product_id.

Code: Select all

$data['products'][] = array(
			'product_id'  => $result['product_id'],

Active Member

Posts

Joined
Thu Jul 09, 2015 5:59 am

Post by Cyto » Mon Jan 18, 2016 6:22 pm

opencartboost wrote:Why do you create new function to get product ID?
Every product array contain product_id.

Code: Select all

$data['products'][] = array(
			'product_id'  => $result['product_id'],
I know that, thats an array of products. I want to retrieve a single product data by using a random (exisitng) product id. Something like this: getProductByID(123)
Will get me: product data (name, price etc).

Newbie

Posts

Joined
Fri Oct 17, 2014 8:30 pm

Post by Cyto » Thu Jan 21, 2016 11:43 pm

bump

Newbie

Posts

Joined
Fri Oct 17, 2014 8:30 pm
Who is online

Users browsing this forum: No registered users and 9 guests