pass array from php file to phtml? The 2019 Stack Overflow Developer Survey Results Are Inlayout handle not working in custom emailProgramatically Sending Transactional Emails Doesn't Include ProductsLocaly made php to magento directory- magento 2Set custom price of product when adding to cart code not workingwhich phtml file is use for New Order Confirmation Template for Guest/Seller?How to change the email template depending on shipping method?Magento 2: How to edit existing Order without cancel?Add “Tax amount” to totals in “New order” email templateRequest for quote and checkout at same timeHow to send a purchase email to the suppliers manually by clicking a button on order detail page in Magento 2?

Deal with toxic manager when you can't quit

Falsification in Math vs Science

Write faster on AT24C32

Can one be advised by a professor who is very far away?

Do these rules for Critical Successes and Critical Failures seem Fair?

Is there any way to tell whether the shot is going to hit you or not?

How to deal with fear of taking dependencies

Right tool to dig six foot holes?

Multiply Two Integer Polynomials

What does ひと匙 mean in this manga and has it been used colloquially?

How to save as into a customized destination on macOS?

Worn-tile Scrabble

Why do we hear so much about the Trump administration deciding to impose and then remove tariffs?

How come people say “Would of”?

Did Scotland spend $250,000 for the slogan "Welcome to Scotland"?

Did 3000BC Egyptians use meteoric iron weapons?

How to type this arrow in math mode?

Origin of "cooter" meaning "vagina"

Is this app Icon Browser Safe/Legit?

What is the most effective way of iterating a std::vector and why?

How can I autofill dates in Excel excluding Sunday?

Have you ever entered Singapore using a different passport or name?

Why is the maximum length of OpenWrt’s root password 8 characters?

Earliest use of the term "Galois extension"?



pass array from php file to phtml?



The 2019 Stack Overflow Developer Survey Results Are Inlayout handle not working in custom emailProgramatically Sending Transactional Emails Doesn't Include ProductsLocaly made php to magento directory- magento 2Set custom price of product when adding to cart code not workingwhich phtml file is use for New Order Confirmation Template for Guest/Seller?How to change the email template depending on shipping method?Magento 2: How to edit existing Order without cancel?Add “Tax amount” to totals in “New order” email templateRequest for quote and checkout at same timeHow to send a purchase email to the suppliers manually by clicking a button on order detail page in Magento 2?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















i use observer on order place . sales_model_service_quote_submit_before when order is place i get order items and each item has a seller id . i get email from seller ids.
and now send mail to those seller which has items in this order.



my observer code is



 public function execute(MagentoFrameworkEventObserver $observer)

$orderData=array();
$order = $observer->getData('order');
$quote = $observer->getData('quote');
$quoteItems = $quote->getAllVisibleItems();
$orderData['customerName']=$order->getCustomerFirstname().' '.$order->getCustomerLastname();
foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")

$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][]=$quoteItem->getName();
$orderData['productinfo'][]=$quoteItem->getSku();
$orderData['productinfo'][]=$quoteItem->getQty();
$orderData['productinfo'][]=$quoteItem->getPrice();



//$this->logger->info(print_r($orderData, true));

$this->Seller_mail_method($orderData);

return $this;



public function Seller_mail_method($getOrderParams)
/* Receiver Detail */
$receiverInfo = [
'name' => 'Reciver Name',
'email' => $getOrderParams['SellerEmail']
];

$store = $this->storeManager->getStore();
$TemplateParameter=[
'customerName'=>$getOrderParams['customerName'],
'orderItems'=>$getOrderParams['productinfo']
];

$transport = $this->transportBuilder->setTemplateIdentifier(
'seller_order_email_template'
)->setTemplateOptions(
['area' => 'frontend', 'store' => $store->getId()]
)->addTo(
$receiverInfo['email'], $receiverInfo['name']
)->setTemplateVars(
$TemplateParameter
)->setFrom(
'general'
)->getTransport();

try
// Send an email
$transport->sendMessage();
catch (Exception $e)
// Write a log message whenever get errors
$this->logger->critical($e->getMessage());




my seller_email_template.html code is



template config_path="design/email/header_template" <!-- pathe of template header-->

<table>
<tr class="email-intro">
<td>
<p class="greeting">row</p>

</td>
</tr>
<tr class="email-information">
<td>

<table class="email-items">
<tbody>
layout handle="sellers_email_order_items" area="frontend"
</tbody>
</table>
</td>
</tr>
</table>

template config_path="design/email/footer_template"


and phtml file code is



<?php

echo "testing";



?>
<?php //$_order = $block->getOrder() ?>
<?php if ($items): ?>
<?php //$_items = $_order->getAllItems(); ?>
<table class="email-items">
<thead>
<tr>
<th class="item-info">
<?= /* @escapeNotVerified */ __('Items') ?>
</th>
<th class="item-qty">
<?= /* @escapeNotVerified */ __('Qty') ?>
</th>
<th class="item-price">
<?= /* @escapeNotVerified */ __('Price') ?>
</th>
</tr>
</thead>
<?php foreach ($items as $item): ?>
// Here want to set items
<!-- <tr>-->
<!-- <td>-->
<!-- --><?//= $item["product"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["qty"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["price"]; ?>
<!-- </td>-->
<!-- </tr>-->
<?php endforeach; ?>
<tfoot class="order-totals">

</tfoot>
</table>
<?php endif; ?>


How can set $orderItems in phtm file ? my mail send correctly but now just set content.
please guide me .



there is problem in my code how can manage to set orderItems of same sellers. when call mail method these problem will resolve later . But now 1 order 1 item of 1 seller. Thanks










share|improve this question
























  • Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

    – HelgeB
    yesterday











  • @HelgeB ! i edit my question please review question if you understand . please

    – HaFiz Umer
    yesterday











  • i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

    – HaFiz Umer
    yesterday

















1















i use observer on order place . sales_model_service_quote_submit_before when order is place i get order items and each item has a seller id . i get email from seller ids.
and now send mail to those seller which has items in this order.



my observer code is



 public function execute(MagentoFrameworkEventObserver $observer)

$orderData=array();
$order = $observer->getData('order');
$quote = $observer->getData('quote');
$quoteItems = $quote->getAllVisibleItems();
$orderData['customerName']=$order->getCustomerFirstname().' '.$order->getCustomerLastname();
foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")

$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][]=$quoteItem->getName();
$orderData['productinfo'][]=$quoteItem->getSku();
$orderData['productinfo'][]=$quoteItem->getQty();
$orderData['productinfo'][]=$quoteItem->getPrice();



//$this->logger->info(print_r($orderData, true));

$this->Seller_mail_method($orderData);

return $this;



public function Seller_mail_method($getOrderParams)
/* Receiver Detail */
$receiverInfo = [
'name' => 'Reciver Name',
'email' => $getOrderParams['SellerEmail']
];

$store = $this->storeManager->getStore();
$TemplateParameter=[
'customerName'=>$getOrderParams['customerName'],
'orderItems'=>$getOrderParams['productinfo']
];

$transport = $this->transportBuilder->setTemplateIdentifier(
'seller_order_email_template'
)->setTemplateOptions(
['area' => 'frontend', 'store' => $store->getId()]
)->addTo(
$receiverInfo['email'], $receiverInfo['name']
)->setTemplateVars(
$TemplateParameter
)->setFrom(
'general'
)->getTransport();

try
// Send an email
$transport->sendMessage();
catch (Exception $e)
// Write a log message whenever get errors
$this->logger->critical($e->getMessage());




my seller_email_template.html code is



template config_path="design/email/header_template" <!-- pathe of template header-->

<table>
<tr class="email-intro">
<td>
<p class="greeting">row</p>

</td>
</tr>
<tr class="email-information">
<td>

<table class="email-items">
<tbody>
layout handle="sellers_email_order_items" area="frontend"
</tbody>
</table>
</td>
</tr>
</table>

template config_path="design/email/footer_template"


and phtml file code is



<?php

echo "testing";



?>
<?php //$_order = $block->getOrder() ?>
<?php if ($items): ?>
<?php //$_items = $_order->getAllItems(); ?>
<table class="email-items">
<thead>
<tr>
<th class="item-info">
<?= /* @escapeNotVerified */ __('Items') ?>
</th>
<th class="item-qty">
<?= /* @escapeNotVerified */ __('Qty') ?>
</th>
<th class="item-price">
<?= /* @escapeNotVerified */ __('Price') ?>
</th>
</tr>
</thead>
<?php foreach ($items as $item): ?>
// Here want to set items
<!-- <tr>-->
<!-- <td>-->
<!-- --><?//= $item["product"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["qty"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["price"]; ?>
<!-- </td>-->
<!-- </tr>-->
<?php endforeach; ?>
<tfoot class="order-totals">

</tfoot>
</table>
<?php endif; ?>


How can set $orderItems in phtm file ? my mail send correctly but now just set content.
please guide me .



there is problem in my code how can manage to set orderItems of same sellers. when call mail method these problem will resolve later . But now 1 order 1 item of 1 seller. Thanks










share|improve this question
























  • Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

    – HelgeB
    yesterday











  • @HelgeB ! i edit my question please review question if you understand . please

    – HaFiz Umer
    yesterday











  • i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

    – HaFiz Umer
    yesterday













1












1








1








i use observer on order place . sales_model_service_quote_submit_before when order is place i get order items and each item has a seller id . i get email from seller ids.
and now send mail to those seller which has items in this order.



my observer code is



 public function execute(MagentoFrameworkEventObserver $observer)

$orderData=array();
$order = $observer->getData('order');
$quote = $observer->getData('quote');
$quoteItems = $quote->getAllVisibleItems();
$orderData['customerName']=$order->getCustomerFirstname().' '.$order->getCustomerLastname();
foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")

$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][]=$quoteItem->getName();
$orderData['productinfo'][]=$quoteItem->getSku();
$orderData['productinfo'][]=$quoteItem->getQty();
$orderData['productinfo'][]=$quoteItem->getPrice();



//$this->logger->info(print_r($orderData, true));

$this->Seller_mail_method($orderData);

return $this;



public function Seller_mail_method($getOrderParams)
/* Receiver Detail */
$receiverInfo = [
'name' => 'Reciver Name',
'email' => $getOrderParams['SellerEmail']
];

$store = $this->storeManager->getStore();
$TemplateParameter=[
'customerName'=>$getOrderParams['customerName'],
'orderItems'=>$getOrderParams['productinfo']
];

$transport = $this->transportBuilder->setTemplateIdentifier(
'seller_order_email_template'
)->setTemplateOptions(
['area' => 'frontend', 'store' => $store->getId()]
)->addTo(
$receiverInfo['email'], $receiverInfo['name']
)->setTemplateVars(
$TemplateParameter
)->setFrom(
'general'
)->getTransport();

try
// Send an email
$transport->sendMessage();
catch (Exception $e)
// Write a log message whenever get errors
$this->logger->critical($e->getMessage());




my seller_email_template.html code is



template config_path="design/email/header_template" <!-- pathe of template header-->

<table>
<tr class="email-intro">
<td>
<p class="greeting">row</p>

</td>
</tr>
<tr class="email-information">
<td>

<table class="email-items">
<tbody>
layout handle="sellers_email_order_items" area="frontend"
</tbody>
</table>
</td>
</tr>
</table>

template config_path="design/email/footer_template"


and phtml file code is



<?php

echo "testing";



?>
<?php //$_order = $block->getOrder() ?>
<?php if ($items): ?>
<?php //$_items = $_order->getAllItems(); ?>
<table class="email-items">
<thead>
<tr>
<th class="item-info">
<?= /* @escapeNotVerified */ __('Items') ?>
</th>
<th class="item-qty">
<?= /* @escapeNotVerified */ __('Qty') ?>
</th>
<th class="item-price">
<?= /* @escapeNotVerified */ __('Price') ?>
</th>
</tr>
</thead>
<?php foreach ($items as $item): ?>
// Here want to set items
<!-- <tr>-->
<!-- <td>-->
<!-- --><?//= $item["product"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["qty"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["price"]; ?>
<!-- </td>-->
<!-- </tr>-->
<?php endforeach; ?>
<tfoot class="order-totals">

</tfoot>
</table>
<?php endif; ?>


How can set $orderItems in phtm file ? my mail send correctly but now just set content.
please guide me .



there is problem in my code how can manage to set orderItems of same sellers. when call mail method these problem will resolve later . But now 1 order 1 item of 1 seller. Thanks










share|improve this question
















i use observer on order place . sales_model_service_quote_submit_before when order is place i get order items and each item has a seller id . i get email from seller ids.
and now send mail to those seller which has items in this order.



my observer code is



 public function execute(MagentoFrameworkEventObserver $observer)

$orderData=array();
$order = $observer->getData('order');
$quote = $observer->getData('quote');
$quoteItems = $quote->getAllVisibleItems();
$orderData['customerName']=$order->getCustomerFirstname().' '.$order->getCustomerLastname();
foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")

$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][]=$quoteItem->getName();
$orderData['productinfo'][]=$quoteItem->getSku();
$orderData['productinfo'][]=$quoteItem->getQty();
$orderData['productinfo'][]=$quoteItem->getPrice();



//$this->logger->info(print_r($orderData, true));

$this->Seller_mail_method($orderData);

return $this;



public function Seller_mail_method($getOrderParams)
/* Receiver Detail */
$receiverInfo = [
'name' => 'Reciver Name',
'email' => $getOrderParams['SellerEmail']
];

$store = $this->storeManager->getStore();
$TemplateParameter=[
'customerName'=>$getOrderParams['customerName'],
'orderItems'=>$getOrderParams['productinfo']
];

$transport = $this->transportBuilder->setTemplateIdentifier(
'seller_order_email_template'
)->setTemplateOptions(
['area' => 'frontend', 'store' => $store->getId()]
)->addTo(
$receiverInfo['email'], $receiverInfo['name']
)->setTemplateVars(
$TemplateParameter
)->setFrom(
'general'
)->getTransport();

try
// Send an email
$transport->sendMessage();
catch (Exception $e)
// Write a log message whenever get errors
$this->logger->critical($e->getMessage());




my seller_email_template.html code is



template config_path="design/email/header_template" <!-- pathe of template header-->

<table>
<tr class="email-intro">
<td>
<p class="greeting">row</p>

</td>
</tr>
<tr class="email-information">
<td>

<table class="email-items">
<tbody>
layout handle="sellers_email_order_items" area="frontend"
</tbody>
</table>
</td>
</tr>
</table>

template config_path="design/email/footer_template"


and phtml file code is



<?php

echo "testing";



?>
<?php //$_order = $block->getOrder() ?>
<?php if ($items): ?>
<?php //$_items = $_order->getAllItems(); ?>
<table class="email-items">
<thead>
<tr>
<th class="item-info">
<?= /* @escapeNotVerified */ __('Items') ?>
</th>
<th class="item-qty">
<?= /* @escapeNotVerified */ __('Qty') ?>
</th>
<th class="item-price">
<?= /* @escapeNotVerified */ __('Price') ?>
</th>
</tr>
</thead>
<?php foreach ($items as $item): ?>
// Here want to set items
<!-- <tr>-->
<!-- <td>-->
<!-- --><?//= $item["product"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["qty"]; ?>
<!-- </td>-->
<!-- <td>-->
<!-- --><?//= $item["price"]; ?>
<!-- </td>-->
<!-- </tr>-->
<?php endforeach; ?>
<tfoot class="order-totals">

</tfoot>
</table>
<?php endif; ?>


How can set $orderItems in phtm file ? my mail send correctly but now just set content.
please guide me .



there is problem in my code how can manage to set orderItems of same sellers. when call mail method these problem will resolve later . But now 1 order 1 item of 1 seller. Thanks







magento2 event-observer email-templates phtml getarray






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









HelgeB

3,1981323




3,1981323










asked yesterday









HaFiz UmerHaFiz Umer

4319




4319












  • Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

    – HelgeB
    yesterday











  • @HelgeB ! i edit my question please review question if you understand . please

    – HaFiz Umer
    yesterday











  • i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

    – HaFiz Umer
    yesterday

















  • Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

    – HelgeB
    yesterday











  • @HelgeB ! i edit my question please review question if you understand . please

    – HaFiz Umer
    yesterday











  • i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

    – HaFiz Umer
    yesterday
















Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

– HelgeB
yesterday





Can you please provide some more information about the observer? Which event is used and the complete method. As far as I understand you want to pass data from that observer to the item renderer for transactional emails

– HelgeB
yesterday













@HelgeB ! i edit my question please review question if you understand . please

– HaFiz Umer
yesterday





@HelgeB ! i edit my question please review question if you understand . please

– HaFiz Umer
yesterday













i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

– HaFiz Umer
yesterday





i think may be session use here . to store orderitems in session and get session in phtml . is this suitable or other plz guide me

– HaFiz Umer
yesterday










1 Answer
1






active

oldest

votes


















1














OK, if you send the mail from your observer, it is possible to pass the object to the item renderer template. As far as I can see the passing to seller_email_template.html already works since you use $customerName , so you just have to pass the $orderItems to the item renderer block.



I guess with the following changes you should get the order items in your email:



seller_email_template.html:



layout handle="sellers_email_order_items" orderItems=$orderItems area="frontend"


items.phtml:



<?php $items = $block->getOrderItems();?>
<?php if ($items): ?>
...


In your observer you should populate the array with the keys you want to access later in the template. I guess you should change the foreach loop like this:



foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")
$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][] = [
'name' => $quoteItem->getName(),
'sku' => $quoteItem->getSku(),
'qty' => $quoteItem->getQty(),
'price' => $quoteItem->getPrice()
];







share|improve this answer

























  • let me try it wait . . . .

    – HaFiz Umer
    yesterday











  • You have also an error where you populate the array, I have updated the answer regarding that error

    – HelgeB
    yesterday












  • HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

    – HaFiz Umer
    yesterday












  • my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

    – HaFiz Umer
    yesterday












  • Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

    – HelgeB
    yesterday











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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269319%2fpass-array-from-php-file-to-phtml%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









1














OK, if you send the mail from your observer, it is possible to pass the object to the item renderer template. As far as I can see the passing to seller_email_template.html already works since you use $customerName , so you just have to pass the $orderItems to the item renderer block.



I guess with the following changes you should get the order items in your email:



seller_email_template.html:



layout handle="sellers_email_order_items" orderItems=$orderItems area="frontend"


items.phtml:



<?php $items = $block->getOrderItems();?>
<?php if ($items): ?>
...


In your observer you should populate the array with the keys you want to access later in the template. I guess you should change the foreach loop like this:



foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")
$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][] = [
'name' => $quoteItem->getName(),
'sku' => $quoteItem->getSku(),
'qty' => $quoteItem->getQty(),
'price' => $quoteItem->getPrice()
];







share|improve this answer

























  • let me try it wait . . . .

    – HaFiz Umer
    yesterday











  • You have also an error where you populate the array, I have updated the answer regarding that error

    – HelgeB
    yesterday












  • HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

    – HaFiz Umer
    yesterday












  • my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

    – HaFiz Umer
    yesterday












  • Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

    – HelgeB
    yesterday















1














OK, if you send the mail from your observer, it is possible to pass the object to the item renderer template. As far as I can see the passing to seller_email_template.html already works since you use $customerName , so you just have to pass the $orderItems to the item renderer block.



I guess with the following changes you should get the order items in your email:



seller_email_template.html:



layout handle="sellers_email_order_items" orderItems=$orderItems area="frontend"


items.phtml:



<?php $items = $block->getOrderItems();?>
<?php if ($items): ?>
...


In your observer you should populate the array with the keys you want to access later in the template. I guess you should change the foreach loop like this:



foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")
$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][] = [
'name' => $quoteItem->getName(),
'sku' => $quoteItem->getSku(),
'qty' => $quoteItem->getQty(),
'price' => $quoteItem->getPrice()
];







share|improve this answer

























  • let me try it wait . . . .

    – HaFiz Umer
    yesterday











  • You have also an error where you populate the array, I have updated the answer regarding that error

    – HelgeB
    yesterday












  • HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

    – HaFiz Umer
    yesterday












  • my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

    – HaFiz Umer
    yesterday












  • Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

    – HelgeB
    yesterday













1












1








1







OK, if you send the mail from your observer, it is possible to pass the object to the item renderer template. As far as I can see the passing to seller_email_template.html already works since you use $customerName , so you just have to pass the $orderItems to the item renderer block.



I guess with the following changes you should get the order items in your email:



seller_email_template.html:



layout handle="sellers_email_order_items" orderItems=$orderItems area="frontend"


items.phtml:



<?php $items = $block->getOrderItems();?>
<?php if ($items): ?>
...


In your observer you should populate the array with the keys you want to access later in the template. I guess you should change the foreach loop like this:



foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")
$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][] = [
'name' => $quoteItem->getName(),
'sku' => $quoteItem->getSku(),
'qty' => $quoteItem->getQty(),
'price' => $quoteItem->getPrice()
];







share|improve this answer















OK, if you send the mail from your observer, it is possible to pass the object to the item renderer template. As far as I can see the passing to seller_email_template.html already works since you use $customerName , so you just have to pass the $orderItems to the item renderer block.



I guess with the following changes you should get the order items in your email:



seller_email_template.html:



layout handle="sellers_email_order_items" orderItems=$orderItems area="frontend"


items.phtml:



<?php $items = $block->getOrderItems();?>
<?php if ($items): ?>
...


In your observer you should populate the array with the keys you want to access later in the template. I guess you should change the foreach loop like this:



foreach ($quoteItems as $quoteItem)
if ($quoteItem->getCurrentSellerId() != "")
$userdetail=$this->userFactory->create()->load($quoteItem->getCurrentSellerId());
$orderData['SellerEmail']=$userdetail->getEmail();
$orderData['productinfo'][] = [
'name' => $quoteItem->getName(),
'sku' => $quoteItem->getSku(),
'qty' => $quoteItem->getQty(),
'price' => $quoteItem->getPrice()
];








share|improve this answer














share|improve this answer



share|improve this answer








edited yesterday

























answered yesterday









HelgeBHelgeB

3,1981323




3,1981323












  • let me try it wait . . . .

    – HaFiz Umer
    yesterday











  • You have also an error where you populate the array, I have updated the answer regarding that error

    – HelgeB
    yesterday












  • HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

    – HaFiz Umer
    yesterday












  • my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

    – HaFiz Umer
    yesterday












  • Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

    – HelgeB
    yesterday

















  • let me try it wait . . . .

    – HaFiz Umer
    yesterday











  • You have also an error where you populate the array, I have updated the answer regarding that error

    – HelgeB
    yesterday












  • HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

    – HaFiz Umer
    yesterday












  • my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

    – HaFiz Umer
    yesterday












  • Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

    – HelgeB
    yesterday
















let me try it wait . . . .

– HaFiz Umer
yesterday





let me try it wait . . . .

– HaFiz Umer
yesterday













You have also an error where you populate the array, I have updated the answer regarding that error

– HelgeB
yesterday






You have also an error where you populate the array, I have updated the answer regarding that error

– HelgeB
yesterday














HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

– HaFiz Umer
yesterday






HelgeB bro ! error in mail Error filtering template: CodilityVendorOrderObserverOrderItemToOrder does not implement BlockInterface My OderItemToOrder.php is not implemented with block interface. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd" label="Email Product List" design_abstraction="custom"> <block class="CodilityVendorOrderObserverOrderItemToOrder" name="seller_items_block" template="Codility_VendorOrder::email/SellerItems.phtml" /> </body>

– HaFiz Umer
yesterday














my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

– HaFiz Umer
yesterday






my ` CodilityVendorOrderObserverOrderItemToOrder` in implemented with ObserverInterface. Thats why <?php $items = $block->getOrderItems();?> not work. how can do that

– HaFiz Umer
yesterday














Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

– HelgeB
yesterday





Then you need to create a block there you can't use an observer in the layout :-) Just create a simple block which extends MagentoFrameworkViewElementTemplate and put that in your layout.

– HelgeB
yesterday

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f269319%2fpass-array-from-php-file-to-phtml%23new-answer', 'question_page');

);

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







Popular posts from this blog

Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림