Mitchell Bray
Mitchell Bray

Reputation: 558

opencart get product by model name

Is there any way to load a product by its model name in opencart, The site i am working on has many related products with the same sub model number. see below for example.

product model names:

thq-0034,
thq-0034-big,
thq-0034-small,
thq-0034-blue,
thq-0035,
thq-0035-big,
thq-0035-small,
thq-0035-blue,

ie. put a link from product thq-0034/5's product page to the thq-0034/5-big or thq-0034/5-blue Companion product without making them all related products in the admin menu.

Upvotes: 1

Views: 2055

Answers (1)

Jay Gilford
Jay Gilford

Reputation: 15151

The easiest way to do this would be to run a query on the product table

$result = $this->db->query("SELECT product_id FROM `" . DB_PREFIX . "product` WHERE `model` LIKE 'thq-0034%'");

This will return an array of results, with a product_id key for each product matching

Upvotes: 2

Related Questions