How to display product by using order Item_Id in Magento 2?How to get Quantity Order for product to display on Product PageGetting the product info from different store in checkout processHow to add product in Magento using REST API?Display Product Id & Name of Order in custom pageMagento : How to Display Products as Default Display ProductMagento 2 Add new field to Magento_User admin formMagento 2: How to display the category in product URL?Magento 2 - How to add,save,display custom Field in Product Edit form using UiComponent?How to create custom form in Magento 2.2.3How do I add product data and directly to the database, which tables need to be updated in what order?
Evaluate the limit the following series
How important are the Author's mood and feelings for writing a story?
How to get a type of "screech" on guitar
How to determine Platform Event Size in Apex to ensure to be within < 1 MB
Are there any satellites in geosynchronous but not geostationary orbits?
What is a Romeo Word™?
Why are there few or no black super GMs?
How should I interpret a promising preprint that was never published in a peer-reviewed journal?
"Je suis petite, moi?", purpose of the "moi"?
Why should fork() have been designed to return a file descriptor?
Do Australia and New Zealand have a travel ban on Somalis (like Wikipedia says)?
Why did my "seldom" get corrected?
To what extent does asymmetric cryptography secure bitcoin transactions?
Simplest instruction set that has an c++/C compiler to write an emulator for?
What would be the safest way to drop thousands of small, hard objects from a typical, high wing, GA airplane?
Do higher dimensions have axes?
Function over a list that depends on the index
Does unblocking power bar outlets through short extension cords increase fire risk?
Does a hash function have a Upper bound on input length?
Suggestions for how to track down the source of this force:source:push error?
I want light controlled by one switch, not two
What are my hardware upgrade optoins for a late 2009 iMac?
Equality of complex numbers in general
Extract the attribute names from a large number of Shapefiles
How to display product by using order Item_Id in Magento 2?
How to get Quantity Order for product to display on Product PageGetting the product info from different store in checkout processHow to add product in Magento using REST API?Display Product Id & Name of Order in custom pageMagento : How to Display Products as Default Display ProductMagento 2 Add new field to Magento_User admin formMagento 2: How to display the category in product URL?Magento 2 - How to add,save,display custom Field in Product Edit form using UiComponent?How to create custom form in Magento 2.2.3How do I add product data and directly to the database, which tables need to be updated in what order?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm trying to show product detail by order Item_Id. I have this page:

When we click on Order Detail, it will get the item (2) to show product detail we've chosen. Here is my code to show this page:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->
create('MagentoSalesModelOrderItem')->getCollection();
echo "<p style='color:red;
font-size:20px;'>
Product Ordered
</p>";
?>
<div class="table-wrapper orders-history">
<table class="data table table-order-items history" id="my-orders-
table">
<caption class="table-caption"><?= $block->escapeHtml(__('Orders'))
?></caption>
<thead>
<tr>
<th scope="col" class="col orderitemid"> <?= $block->escapeHtml(__('OrderItem' )) ?></th>
<th scope="col" class="col image "> <?= $block->escapeHtml(__('Product Image')) ?></th>
<th scope="col" class="col name "> <?= $block->escapeHtml(__('Product Name' )) ?></th>
<th scope="col" class="col Qty "> <?= $block->escapeHtml(__('Qty' )) ?></th>
<th scope="col" class="col Price "> <?= $block->escapeHtml(__('Price' )) ?></th>
<th scope="col" class="col Total "> <?= $block->escapeHtml(__('Total' )) ?></th>
<th scope="col" class="col Action "> <?= $block->escapeHtml(__('Action' )) ?></th>
</tr>
</thead>
<tbody>
<?php foreach($orders as $item): ?>
<?php
$_product = $objectManager->get('MagentoCatalogModelProduct')->load($item->getProductId());
$imageHelper = $objectManager->get('MagentoCatalogHelperImage');
$image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getImage())->resize(100, 100)->getUrl();
?>
<tr>
<td data-th="OrderItem "class="col orderitemid"> <?php echo $item->getItemId(); ?></td>
<td data-th="Product Image"class="col image "> <img src="<?= $image_url ?>" width="75px" height="75px"></td>
<td data-th="Product Name "class="col name "> <?php echo $item->getName(); ?></td>
<td data-th="Qty "class="col qty "> <?php echo $item->getQtyOrdered(); ?></td>
<td data-th="Price "class="col price "> <?php echo $item->getPrice(); ?></td>
<td data-th="Subtotal "class="col subtotal"> <?php echo $item->getBaseRowTotalInclTax(); ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>">Order Detail</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Can anyone help the next step?
Thanks a lot.
magento2 product
add a comment |
I'm trying to show product detail by order Item_Id. I have this page:

When we click on Order Detail, it will get the item (2) to show product detail we've chosen. Here is my code to show this page:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->
create('MagentoSalesModelOrderItem')->getCollection();
echo "<p style='color:red;
font-size:20px;'>
Product Ordered
</p>";
?>
<div class="table-wrapper orders-history">
<table class="data table table-order-items history" id="my-orders-
table">
<caption class="table-caption"><?= $block->escapeHtml(__('Orders'))
?></caption>
<thead>
<tr>
<th scope="col" class="col orderitemid"> <?= $block->escapeHtml(__('OrderItem' )) ?></th>
<th scope="col" class="col image "> <?= $block->escapeHtml(__('Product Image')) ?></th>
<th scope="col" class="col name "> <?= $block->escapeHtml(__('Product Name' )) ?></th>
<th scope="col" class="col Qty "> <?= $block->escapeHtml(__('Qty' )) ?></th>
<th scope="col" class="col Price "> <?= $block->escapeHtml(__('Price' )) ?></th>
<th scope="col" class="col Total "> <?= $block->escapeHtml(__('Total' )) ?></th>
<th scope="col" class="col Action "> <?= $block->escapeHtml(__('Action' )) ?></th>
</tr>
</thead>
<tbody>
<?php foreach($orders as $item): ?>
<?php
$_product = $objectManager->get('MagentoCatalogModelProduct')->load($item->getProductId());
$imageHelper = $objectManager->get('MagentoCatalogHelperImage');
$image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getImage())->resize(100, 100)->getUrl();
?>
<tr>
<td data-th="OrderItem "class="col orderitemid"> <?php echo $item->getItemId(); ?></td>
<td data-th="Product Image"class="col image "> <img src="<?= $image_url ?>" width="75px" height="75px"></td>
<td data-th="Product Name "class="col name "> <?php echo $item->getName(); ?></td>
<td data-th="Qty "class="col qty "> <?php echo $item->getQtyOrdered(); ?></td>
<td data-th="Price "class="col price "> <?php echo $item->getPrice(); ?></td>
<td data-th="Subtotal "class="col subtotal"> <?php echo $item->getBaseRowTotalInclTax(); ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>">Order Detail</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Can anyone help the next step?
Thanks a lot.
magento2 product
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12
add a comment |
I'm trying to show product detail by order Item_Id. I have this page:

When we click on Order Detail, it will get the item (2) to show product detail we've chosen. Here is my code to show this page:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->
create('MagentoSalesModelOrderItem')->getCollection();
echo "<p style='color:red;
font-size:20px;'>
Product Ordered
</p>";
?>
<div class="table-wrapper orders-history">
<table class="data table table-order-items history" id="my-orders-
table">
<caption class="table-caption"><?= $block->escapeHtml(__('Orders'))
?></caption>
<thead>
<tr>
<th scope="col" class="col orderitemid"> <?= $block->escapeHtml(__('OrderItem' )) ?></th>
<th scope="col" class="col image "> <?= $block->escapeHtml(__('Product Image')) ?></th>
<th scope="col" class="col name "> <?= $block->escapeHtml(__('Product Name' )) ?></th>
<th scope="col" class="col Qty "> <?= $block->escapeHtml(__('Qty' )) ?></th>
<th scope="col" class="col Price "> <?= $block->escapeHtml(__('Price' )) ?></th>
<th scope="col" class="col Total "> <?= $block->escapeHtml(__('Total' )) ?></th>
<th scope="col" class="col Action "> <?= $block->escapeHtml(__('Action' )) ?></th>
</tr>
</thead>
<tbody>
<?php foreach($orders as $item): ?>
<?php
$_product = $objectManager->get('MagentoCatalogModelProduct')->load($item->getProductId());
$imageHelper = $objectManager->get('MagentoCatalogHelperImage');
$image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getImage())->resize(100, 100)->getUrl();
?>
<tr>
<td data-th="OrderItem "class="col orderitemid"> <?php echo $item->getItemId(); ?></td>
<td data-th="Product Image"class="col image "> <img src="<?= $image_url ?>" width="75px" height="75px"></td>
<td data-th="Product Name "class="col name "> <?php echo $item->getName(); ?></td>
<td data-th="Qty "class="col qty "> <?php echo $item->getQtyOrdered(); ?></td>
<td data-th="Price "class="col price "> <?php echo $item->getPrice(); ?></td>
<td data-th="Subtotal "class="col subtotal"> <?php echo $item->getBaseRowTotalInclTax(); ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>">Order Detail</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Can anyone help the next step?
Thanks a lot.
magento2 product
I'm trying to show product detail by order Item_Id. I have this page:

When we click on Order Detail, it will get the item (2) to show product detail we've chosen. Here is my code to show this page:
<?php
$objectManager = MagentoFrameworkAppObjectManager::getInstance();
$orders = $objectManager->
create('MagentoSalesModelOrderItem')->getCollection();
echo "<p style='color:red;
font-size:20px;'>
Product Ordered
</p>";
?>
<div class="table-wrapper orders-history">
<table class="data table table-order-items history" id="my-orders-
table">
<caption class="table-caption"><?= $block->escapeHtml(__('Orders'))
?></caption>
<thead>
<tr>
<th scope="col" class="col orderitemid"> <?= $block->escapeHtml(__('OrderItem' )) ?></th>
<th scope="col" class="col image "> <?= $block->escapeHtml(__('Product Image')) ?></th>
<th scope="col" class="col name "> <?= $block->escapeHtml(__('Product Name' )) ?></th>
<th scope="col" class="col Qty "> <?= $block->escapeHtml(__('Qty' )) ?></th>
<th scope="col" class="col Price "> <?= $block->escapeHtml(__('Price' )) ?></th>
<th scope="col" class="col Total "> <?= $block->escapeHtml(__('Total' )) ?></th>
<th scope="col" class="col Action "> <?= $block->escapeHtml(__('Action' )) ?></th>
</tr>
</thead>
<tbody>
<?php foreach($orders as $item): ?>
<?php
$_product = $objectManager->get('MagentoCatalogModelProduct')->load($item->getProductId());
$imageHelper = $objectManager->get('MagentoCatalogHelperImage');
$image_url = $imageHelper->init($_product, 'product_page_image_small')->setImageFile($_product->getImage())->resize(100, 100)->getUrl();
?>
<tr>
<td data-th="OrderItem "class="col orderitemid"> <?php echo $item->getItemId(); ?></td>
<td data-th="Product Image"class="col image "> <img src="<?= $image_url ?>" width="75px" height="75px"></td>
<td data-th="Product Name "class="col name "> <?php echo $item->getName(); ?></td>
<td data-th="Qty "class="col qty "> <?php echo $item->getQtyOrdered(); ?></td>
<td data-th="Price "class="col price "> <?php echo $item->getPrice(); ?></td>
<td data-th="Subtotal "class="col subtotal"> <?php echo $item->getBaseRowTotalInclTax(); ?></td>
<td data-th="<?= $block->escapeHtml(__('Actions')) ?>" class="col actions">
<a href="<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>">Order Detail</a>
</td>
</tr>
<?php endforeach; ?>
</tbody>
Can anyone help the next step?
Thanks a lot.
magento2 product
magento2 product
edited Jul 11 at 9:26
Faisal Sheikh
1549 bronze badges
1549 bronze badges
asked Jul 11 at 8:31
Michael TaoMichael Tao
588 bronze badges
588 bronze badges
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12
add a comment |
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12
add a comment |
1 Answer
1
active
oldest
votes
Remove this code :
<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>
And add this code for redirect to product page :
<?php echo $_product->getProductUrl(); ?>
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "479"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281694%2fhow-to-display-product-by-using-order-item-id-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Remove this code :
<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>
And add this code for redirect to product page :
<?php echo $_product->getProductUrl(); ?>
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
add a comment |
Remove this code :
<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>
And add this code for redirect to product page :
<?php echo $_product->getProductUrl(); ?>
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
add a comment |
Remove this code :
<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>
And add this code for redirect to product page :
<?php echo $_product->getProductUrl(); ?>
Remove this code :
<?php echo $this->getUrl('history/detail/display',['item_id' => $item->getItemId()]); ?>
And add this code for redirect to product page :
<?php echo $_product->getProductUrl(); ?>
answered Jul 11 at 9:07
Rohan HapaniRohan Hapani
7,9214 gold badges21 silver badges65 bronze badges
7,9214 gold badges21 silver badges65 bronze badges
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
add a comment |
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
Thanks for your answer @Rohan. How about the file .phtml I want to show the product
– Michael Tao
Jul 11 at 9:09
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
As I said, It will redirect to product page.
– Rohan Hapani
Jul 11 at 9:10
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f281694%2fhow-to-display-product-by-using-order-item-id-in-magento-2%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
You want to redirect to product page?
– Rohan Hapani
Jul 11 at 8:55
Hi @Rohan. Could you tell me how can I get productUrl to redirect to product page??
– Michael Tao
Jul 17 at 9:09
Please check my answer. using that you can get product URL.
– Rohan Hapani
Jul 17 at 9:12