I have tried to display the data from Quote_item table in the database to file .phtml but it shows this error
the code in Magento/MyHistory/Block/View.php
<?php
namespace Magento\History\Block;
class View extends \Magento\Framework\View\Element\Template
{
public function __constructor(
....
/Magento/Checkout/Model/Cart $cart
....)
{
...
$cart = $cart;
...
}
public function getCartData(){
$data = $this->cart()->create()->getCollection()-
>addFieldToSelect('*');
return $data;
}
}
in Magento/MyHistory/view/frontend/template/index.phtml like this
<?php
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$orders = $objectManager->create('Magento\Checkout\Model\Cart')-
>getCollection();
$orders->addFieldToSelect('*');
?>
<table class="data table" id="test-data-table">
<h2 style="color: red;">Your Order Detail</h2>
<caption class="table-caption">Look at this table</caption>
<thead>
<tr>
<th scope="col" class="col image">Image</th>
<th scope="col" class="col sku">Sku</th>
<th scope="col" class="col name">Name</th>
<th scope="col" class="col qty">Quantity</th>
<th scope="col" class="col created_at">Create at</th>
<th scope="col" class="col updated_at">Update at</th>
</tr>
</thead>
<tbody>
<?php foreach ($orders as $item): ?>
<tr>
<td data-th="Title" class="col sku"><?php echo $item-
>getImage(); ?></td>
<td data-th="Title" class="col sku"><?php echo $item-
>getSku(); ?></td>
<td data-th="Author" class="col name"><?php echo $item-
>getName(); ?></td>
<td data-th="Content" class="col qty"><?php echo $item-
>getQty(); ?></td>
<td data-th="Date" class="col created_at"><?php echo
$item->getCreatedAt(); ?></td>
<td data-th="Date" class="col updated_at"><?php echo
$item->getUpdatedAt(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
Anyone can help me, please?