Friends, I set up a shopping cart with one where I can insert several products. In addition to the cart, I needed to export this list in pdf. When generating the pdf, all items related to the product are displayed, except the product image.
I have two fields in the table where I store the image path: path AND img_product.
I have an example of the filled fields:
path: img/img_products/bd9399cfadbbb51639a033a6a81208bd04cf4b85
img_product: cell.jpg
I’m trying to generate the image this way:
Orders/pdf/download.ctp
<?php foreach((array) $this->request->getSession()->read('cart') as $index=>$cart): ?>
<?= $cart->has('product') ? $this->Html->image('/'.$cart->product->path.$cart->product->img_product, array('width' => '150px', 'class' => 'card-img-top')) : ''?>
<?= $cart->product->name ?>
<?php echo number_format($cart->product->price, 2, ',', '') ?></p>
Quantity: <?= $cart->quantity ?>
Subtotal: R$ <?php $sub = ($cart>product->price * $cart->quantity);
echo number_format($sub, 2, ',', '');
?>
<?php endforeach; ?>
That is, this line does not work:
<?= $cart->has('product') ? $this->Html->image('../'.$cart->product->path.$cart->product->img_product, array('width' => '150px', 'class' => 'card-img-top')) : ''?>
My folder is located at: …/webroot/img/img_products
I appreciate any comments