I have just started using the fantastic community commerce package and have a query about accessing product data. I have had a request to include the product description in the notification emails so I created the override order_receipt.php in application/mail to tweak the output but the $item object containing the ordered product data does not include the product description out of the box.
As the template is using the Product class I thought, much like accessing page properties, I could access a product using its id to get the product description…
$p = \Product::getByID($item->getID());
echo $p->getDesc();
but this says the class is not found?
As a workaround I have been able to update the src Product class to add the description to the $item object…
/**
* @ORM\return mixed
*/
public function getProductDescription()
{
return $this->oiProductDescription;
}
/**
* @ORM\param mixed $oiProductDescription
*/
public function setProductDescription($oiProductDescription)
{
$this->oiProductDescription = $oiProductDescription;
}
$productDescription = $product->getDesc();
which I can then add into the template as…
$item->getProductDescription();
but this is obviously not ideal as it is changing the core package files and subject to breaking when updating.
What would be the best way of accessing the product data within the order_receipt.php template?
Thanks, any pointers gratefully received!