Jump to content

how to display a product by its unique ID


johnpaulvaughan

Recommended Posts

Hi,

Is it possible to output a product (display name, price, url) to a hook based on its unique ID number?

 

Basically, I'm trying to create a module that has a backend form field which the user inputs an ID number of a "special" product... this product is then outputted on the homepage.

 

I know how to create and modify modules, but this has me stumped.

My initial intention was to acutally have a drop down list of all the products, so the user could select it without needing to know the ID number, but that's a bit advanced for me yet :-)

 

Any pointers would be most welcome

 

JP

Link to comment
Share on other sites

So I've done more research and there is a depreciated function "getbyreference"

Does anyone know what the 1.4.x replacement for this code would be?

$myProductId = 10 //ID of my special product

 

$specialProduct = new Product;

$specialProduct->getByReference($myProductId );

$productName = $specialProduct->name|escape:'htmlall':'UTF-8'

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...