Closed AndyJAllen closed 4 years ago
Hi @AndyJAllen. Thank you for your report. To help us process this issue please make sure that you provided the following information:
Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:
@magento give me 2.3-develop instance
- upcoming 2.3.x release
For more details, please, review the Magento Contributor Assistant documentation.
@AndyJAllen do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?
This is what the page source looks like:
I worked around this problem by just replacing \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml with the 2.3.2 version.
It had to do with this code:
<a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank"> <?= $block->escapeHtml($_item->getNumber()) ?> </a>
Which the older version just has:
<?= $block->escapeHtml($_item->getNumber()) ?>
Hi @engcom-Charlie. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).Details
If the issue has a valid description, the label Issue: Format is valid
will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid
appears.
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description
label to the issue by yourself.
[ ] 3. Add Component: XXXXX
label(s) to the ticket, indicating the components it may be related to.
[ ] 4. Verify that the issue is reproducible on 2.3-develop
branchDetails
- Add the comment @magento give me 2.3-develop instance
to deploy test instance on Magento infrastructure.
- If the issue is reproducible on 2.3-develop
branch, please, add the label Reproduced on 2.3.x
.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
[ ] 5. Add label Issue: Confirmed
once verification is complete.
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hello @AndyJAllen
Thank you for contribution and collaboration!
We are not able to reproduce this issue on the lates 2.3-develop branch by provided steps. Magento 2.3-develop has this code too:
Manual testing scenario:
Result: Tracking information sent successfully and email received:
So i have to close this issue. Thanks for your report!
I worked around this problem by just replacing \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml with the 2.3.2 version.
It had to do with this code:
<a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank"> <?= $block->escapeHtml($_item->getNumber()) ?> </a>
Which the older version just has:
<?= $block->escapeHtml($_item->getNumber()) ?>
I had the same problem after upgrading from 2.2.8 to 2.3.3. Your workaround worked for me. Thanks!
I worked around this problem by just replacing \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml with the 2.3.2 version. It had to do with this code:
<a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank"> <?= $block->escapeHtml($_item->getNumber()) ?> </a>
Which the older version just has:<?= $block->escapeHtml($_item->getNumber()) ?>
I had the same problem after upgrading from 2.2.8 to 2.3.3. Your workaround worked for me. Thanks!
I'm glad I was able to help someone. Good luck to you sir.
I have same issue when upgrade magento 2.3.2 to 2.3.3. Shipping created with Carrier: Custom value.
I wonder what we did different than what @engcom-Charlie did for different behavior? I copied all the framework, fedex, sales, and shipping modules from 2.3-develop and still had the issue. No custom modules that would have anything to do with the functionality.
@engcom-Charlie one thing I can tell you that is different in my scenario is I use smartpost which consists of two tracking numbers.
@AndyJAllen i tried again with smart post and two tracking numbers. Result is same:
Oh well; not going to grind my gears over it since I worked around it. Thanks for looking into it @engcom-Charlie
If I hit this again on 2.3.4 I'll dig deeper and report my findings.
@engcom-Charlie I am having the same issue with 2.3.3. I've done a search on the 2.3 repo, Magento 2.3 repo search and can't find any reference to where the method getTrackingUrl is created?
PHP Fatal error: Uncaught Error: Call to a member function getUrl() on null in /var/app/current/vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml:28\nStack trace:\n#0 /var/app/current/vendor/magento/framework/View/TemplateEngine/Php.php(59): include()\n#1 /var/app/current/vendor/magento/framework/View/Element/Template.php(271): Magento\\Framework\\View\\TemplateEngine\\Php->render(Object(Magento\\Framework\\View\\Element\\Template), '/var/app/curren...', Array)\n#2 /var/app/current/vendor/magento/framework/View/Element/Template.php(301): Magento\\Framework\\View\\Element\\Template->fetchView('/var/app/curren...')\n#3 /var/app/current/vendor/magento/framework/View/Element/AbstractBlock.php(1097): Magento\\Framework\\View\\Element\\Template->_toHtml()\n#4 /var/app/current/vendor/magento/framework/View/Element/AbstractBlock.php(1101): Magento\\Framework\\View\\Element\\AbstractBlock->Magento\\Framework\\View\\Element\\{closure}()\n#5 /var/app/current/vendor/magento/framework/View/Element/AbstractBlock.php(671): Magento\\Framework\\V in /var/app/current/vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml on line 28,
@AndyJAllen your work around did the trick.
Hello @aibean
You can find it in module-shipping/Helper/Data.php
I had the same issue after upgrading from Magento 2.3.2 to 2.3.3. The workaround of @AndyJAllen helped me too. Thanks for the tip!
Got the same problem. @AndyJAllen, thank you.
I also have exactly the same problem. Upgraded from 2.2.8 and shipment notification is broken. WIll have to maintain a patch against core for now with the workaround by @AndyJAllen. I really hope this will be re-opened. A lot of people are reporting that this is a problem for them.
EDIT: Can confirm that the workaround works for me.
We are having the exact same problem on 2.3.3. For us it is with UPS shipments. An interesting detail - the first shipment on any order does not have this issue. It is only for orders with split shipments, this will happen on any subsequent shipment made on an order that already has one. Both the weird screen popup, and no email.
@engcom-Charlie - Is it possible that nuance might mean something?
Hello @jove4015 I can't reproduce this issue with split UPS shipments on Magento 2.4-develop.
Testing scenario:
Place order with split shipping via UPS
Ship all
Send tracking info for them
Check mails
Result: Emails: For 1st: 2nd: 3rd 4th:
So no sense to re-open this issue. Thank you for contribution and collaboration!
Can confirm I had the same issue after upgrading from 2.3.2 to 2.3.3 CE. Can confirm @AndyJAllen fix worked, but only after running bin/magento setup:static-content:deploy -f en_GB en_US i.e. Cache flush and restart Varnish was not enough.
This is probably caused by customized e-mail templates based on previous versions.
If you have customized e-mail templates inserting track.phtml this way:
{{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='MyParcelNL_Magento::email/shipment/track.phtml' shipment=$shipment order=$order}}
Try changing that to this so it uses the layout XML:
{{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}
Otherwise track.phtml doesn't receive the (new) argument containing the TrackingUrl object argument defined in the layout xml.
These 2 commits together broke it: https://github.com/magento/magento2/commit/32f0eb73748b00c919385f2bff57087192082921#diff-44dd6522f51e8d3946d9fc5cb2762d23 https://github.com/magento/magento2/commit/4e22c63169cbdb4650be2069e46b782e485b4940
@engcom-Charlie What's the policy on cases like this? It seems like a backward incompatibility issue that's missing from the release notes.
@arnoutvreugdenhil I saw that was the issue as well. Thanks for providing that layout XML. You saved me a lot of time. It was the solution to my issue, and you posted five hours right before! This was meant to be. Haha!
Hi @arnoutvreugdenhil,
Thanks for the correct point on resolving of the issue but looks like the some problems still there. As we know order can have some shipments with relevant tracking information in each. So, if you try send shipping info (for example from admin, using shipment button) Magento using trackCollection in track.phtml will sent all trackings, not from that one you have used.
Above fix by @arnoutvreugdenhil solved the problem for us as well.
Worth noting though, this only happened for orders where there was a custom value for the carrier. (Mentioning this because the tests to confirm the issue above specifically reference using named carriers.)
@aholovan wrote:
Thanks for the correct point on resolving of the issue but looks like the some problems still there. As we know order can have some shipments with relevant tracking information in each. So, if you try send shipping info (for example from admin, using shipment button) Magento using trackCollection in track.phtml will sent all trackings, not from that one you have used.
Andrii's exactly correct; on 2.3.3 (and security patch 2.3.3-p1), we noticed multi-shipment orders had every tracking number in consecutive shipment emails, EG:
Shipment 1, shipped by UPS, Tracking No: 1111111111, email shows the following:
Shipment 2: FedEx, Tracking No: 2222222222, but email shows both shipments incorrectly:
It should only show FedEx for the 2nd shipment email.
The reason is as Andrii pointed out, in in 2.3.3/2.3.3-p1, in: \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml, line 13:
<?php $trackCollection = $_order->getTracksCollection($_shipment->getId()) ?>
This line of code should be:
<?php $trackCollection = $_shipment->getTracksCollection() ?>
The reason being seems to be that the getTracksCollection function, at least on 2.3.3/2.3.3-p1, seems to have lost a constructor where it can be passed a shipment's id to filter the shipment data returned from the order's getTracksCollection. Since it has no constructor that uses the shipment id, it returns all shipments for the order, as we're seeing on 2.3.3/2.3.3-p1.
But, if you are on 2.3.3/2.3.3-p1 and are experiencing this issue, you can override track.phtml and make the change yourself to fix shipment emails until you can upgrade to a Magento verison where the track.phtml code is correct.
Note: We've noticed other shipment email issues still though for 2.3.3/2.3.3-p1, for example- the "shipped by" section isn't showing the full carrier name for us, and the product name is now showing (despite the variables in the template looking correct/being hydrated)... no idea why. :(
Gonna take a look at the changes to the track.phtml/items.phtml files in 2.3.4 / 2.4 pipelines, maybe I can figure it out. :/
facing same issue, trying to send USPS tracking information
I am also getting the same error on Magnto 2.3.4 using Porto 3.2.3 and the solution of @arnoutvreugdenhil did not resolve it. After I was unsuccessful modifying the porto shipment templates, I fell back to the luma templates for new shipment and new shipment guest which both have the following line and the error did not change: {{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
In addition, I changed php max input variables to 10000
I am also getting the same error on Magnto 2.3.4 using Porto 3.2.3 and the solution of @arnoutvreugdenhil did not resolve it. After I was unsuccessful modifying the porto shipment templates, I fell back to the luma templates for new shipment and new shipment guest which both have the following line and the error did not change: {{layout handle="sales_email_order_shipment_items" shipment=$shipment order=$order}}
In addition, I changed php max input variables to 10000
While working on another issue yesterday, I had to delete and re-deploy static content as well as clear all of my cache layers. My error has now resolved with the use of the Luma email templates instead of the Porto templates for New Shipment and New Shipment Guest. (Not sure if changing php max input variables had anything to do with it or not.)
I also faced the same issue for shipping email tracking number for Mangento 2.3.4 update. Unfortunatly AndyJAllen fix to the track.phtml didn't work for me . I think this because of my version is 2.3.4.
But when i change the "is_legacy = 1" for the specific template in the databse in the table "email_template" it worked. Table : email_template Sql : update email_template set is_legacy = 1;
There's an easy fix. The problem is caused by your previous modified email template. You can change back to the default template on the store->configuration->sales->sales emails page. Maybe you can delete the modified email template on Marketing->Email Templates page first, and modify the template again using the current default template. But right now I am just using the default one. Problem solved.
On Thu, Jul 2, 2020 at 9:45 PM viduranishantha notifications@github.com wrote:
I also faced the same issue for shipping email tracking number for Mangento 2.3.4 update. Unfortunatly AndyJAllen fix to the track.phtml didn't work for me . I thinks this because my version is 2.3.4.
But when i change the "is_legacy = 1" for the specific template in the databse in the table "email_template" it worked. Table : email_template Sql : update email_template set is_legacy = 1;
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/magento/magento2/issues/25221#issuecomment-653288593, or unsubscribe https://github.com/notifications/unsubscribe-auth/AELBPKFAJVB4OQIPWZZHBGLRZUZ5JANCNFSM4JDRDNJA .
Hi To fix the issue please replace following file with the magento2 version 2.3.5. vendor/magento/module-sales/view/frontend/templates/email/shipment/track.phtml
Thanks
I worked around this problem by just replacing \vendor\magento\module-sales\view\frontend\templates\email\shipment\track.phtml with the 2.3.2 version. It had to do with this code:
<a href="<?= $block->escapeUrl($block->getTrackingUrl()->getUrl($_item)) ?>" target="_blank"> <?= $block->escapeHtml($_item->getNumber()) ?> </a>
Which the older version just has:<?= $block->escapeHtml($_item->getNumber()) ?>
I had the same problem after upgrading from 2.2.8 to 2.3.3. Your workaround worked for me. Thanks!
The problem returned after upgrading to 2.3.5-p2. Now we're getting logged out after adding the tracking number, but it is saved to the order. I checked the file and this fix is already present. Now I'm looking for a new solution.
Some error present after upgrade to 2.3.5-p2, resolved with AndyJAllen solution and make a static-rebuild
Thanks a lot to AndyJAllen !
same problem with 2.3.5-p2, resolved with AndyJAllen solution and making clear cache and static deploy
Thanks a lot to AndyJAllen !
This issue appears because old Magento version has shipment_new.html with {{block ... }} directive
But now it contaions {{layout ... }} directive.
Layout has "viewModel" tracking_url that block doesn't
`
`
So if you update shipment_new.html and store this email as transactional email (Marketing->Email Templates) in previous Magento version with {{block ...}} directive you get this error because block don't have "viewModel" tracking_url.
The easiest way is to update transaction email and replace {{block ... }} directive with {{layout ...}} directive.
Hi
This issue has been fixed in 2.4.1 .
They have modified vendor/magento/module-sales/view/frontend/layout/sales_email_order_shipment_track.xml as
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<update handle="sales_email_order_shipment_renderers"/>
<body>
<block class="Magento\Sales\Block\Order\Email\Shipment\Items" name="sales.order.email.shipment.track" template="Magento_Sales::email/shipment/track.phtml">
<arguments>
<argument name="tracking_url" xsi:type="object">Magento\Sales\Block\DataProviders\Email\Shipment\TrackingUrl</argument>
</arguments>
</block>
</body>
</page>
AND
vendor/magento/module-sales/Block/Order/Email/Shipment/Items.php as
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Sales\Block\Order\Email\Shipment;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Element\Template\Context;
use Magento\Sales\Api\Data\ShipmentInterface;
use Magento\Sales\Api\Data\OrderInterface;
use Magento\Sales\Api\OrderRepositoryInterface;
use Magento\Sales\Api\ShipmentRepositoryInterface;
/**
* Sales Order Email Shipment items
*
* @api
* @since 100.0.2
*/
class Items extends \Magento\Sales\Block\Items\AbstractItems
{
/**
* @var OrderRepositoryInterface
*/
private $orderRepository;
/**
* @var ShipmentRepositoryInterface
*/
private $shipmentRepository;
/**
* @param Context $context
* @param array $data
* @param OrderRepositoryInterface|null $orderRepository
* @param ShipmentRepositoryInterface|null $creditmemoRepository
*/
public function __construct(
Context $context,
array $data = [],
?OrderRepositoryInterface $orderRepository = null,
?ShipmentRepositoryInterface $creditmemoRepository = null
) {
$this->orderRepository =
$orderRepository ?: ObjectManager::getInstance()->get(OrderRepositoryInterface::class);
$this->shipmentRepository =
$creditmemoRepository ?: ObjectManager::getInstance()->get(ShipmentRepositoryInterface::class);
parent::__construct($context, $data);
}
/**
* Prepare item before output
*
* @param \Magento\Framework\View\Element\AbstractBlock $renderer
* @return void
*/
protected function _prepareItem(\Magento\Framework\View\Element\AbstractBlock $renderer)
{
$renderer->getItem()->setOrder($this->getOrder());
$renderer->getItem()->setSource($this->getShipment());
}
/**
* Returns order.
*
* Custom email templates are only allowed to use scalar values for variable data.
* So order is loaded by order_id, that is passed to block from email template.
* For legacy custom email templates it can pass as an object.
*
* @return OrderInterface|null
* @since 102.1.0
*/
public function getOrder()
{
$order = $this->getData('order');
if ($order !== null) {
return $order;
}
$orderId = (int)$this->getData('order_id');
if ($orderId) {
$order = $this->orderRepository->get($orderId);
$this->setData('order', $order);
}
return $this->getData('order');
}
/**
* Returns shipment.
*
* Custom email templates are only allowed to use scalar values for variable data.
* So shipment is loaded by shipment_id, that is passed to block from email template.
* For legacy custom email templates it can pass as an object.
*
* @return ShipmentInterface|null
* @since 102.1.0
*/
public function getShipment()
{
$shipment = $this->getData('shipment');
if ($shipment !== null) {
return $shipment;
}
$shipmentId = (int)$this->getData('shipment_id');
if ($shipmentId) {
$shipment = $this->shipmentRepository->get($shipmentId);
$this->setData('shipment', $shipment);
}
return $this->getData('shipment');
}
}
Below is the layout handle from shipping template
{{layout handle="sales_email_order_shipment_track" shipment_id=$shipment_id order_id=$order_id}}
OR In old Version You Can use
{{layout handle="sales_email_order_shipment_track" shipment_id=$shipment.entity_id order_id=$order.entity_id}}
NOTE: Just sharing fix from 2.4.1 version . Anyone working on old version can try with it.
I am using Magento 2.4.2. My store was a fresh install of 2.4.1 and was upgraded to 2.4.2. I am using the Codazon Fastest theme and I am having the same problem, even with orders with a single shipment. I am having the problem with UPS specifically. It doesn't appear this has been fixed in 2.4.1 unless my theme is somehow causing the issue. Any help would be appreciated. Thanks!
I'm having the same issue on 2.4.2 as well.
This is probably caused by customized e-mail templates based on previous versions.
If you have customized e-mail templates inserting track.phtml this way:
{{block class='Magento\\Framework\\View\\Element\\Template' area='frontend' template='MyParcelNL_Magento::email/shipment/track.phtml' shipment=$shipment order=$order}}
Try changing that to this so it uses the layout XML:
{{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}
Otherwise track.phtml doesn't receive the (new) argument containing the TrackingUrl object argument defined in the layout xml.
These 2 commits together broke it: https://github.com/magento/magento2/commit/32f0eb73748b00c919385f2bff57087192082921#diff-44dd6522f51e8d3946d9fc5cb2762d23 https://github.com/magento/magento2/commit/4e22c63169cbdb4650be2069e46b782e485b4940
@engcom-Charlie What's the policy on cases like this? It seems like a backward incompatibility issue that's missing from the release notes.
Wow I've been going nuts for 2 days trying to figure this out. Your solution is what fixed it. Thank you!
I'm having the same issue on 2.4.2 as well.
Do check the email template basically below part
{{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}
Should be
{{layout handle="sales_email_order_shipment_track" shipment_id=$shipment.entity_id order_id=$order.entity_id}}
I am using Magento 2.4.2. My store was a fresh install of 2.4.1 and was upgraded to 2.4.2. I am using the Codazon Fastest theme and I am having the same problem, even with orders with a single shipment. I am having the problem with UPS specifically. It doesn't appear this has been fixed in 2.4.1 unless my theme is somehow causing the issue. Any help would be appreciated. Thanks!
Do check email template basically below part
{{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}
Should be
{{layout handle="sales_email_order_shipment_track" shipment_id=$shipment.entity_id order_id=$order.entity_id}}
That works for the emails. But I noticed that those emails that fail, when clicking on the tracking link on either admin or as logged in customer, it throws an exception as well.
Notice: Trying to access array offset on value of type bool in /vendor/magento/module-ups/Model/Carrier.php
The solution provided by enyceedanny worked for me.
If you have customized e-mail templates inserting track.phtml this way: {{block class='Magento\Framework\View\Element\Template' area='frontend' template='MyParcelNL_Magento::email/shipment/track.phtml' shipment=$shipment order=$order}}
Try changing that to this so it uses the layout XML: {{layout handle="sales_email_order_shipment_track" shipment=$shipment order=$order}}
I am also using the codazon fastest theme with 2.4.2. I am going to report this to them so hopefully they update their code and I don't have to make this correction every time there's an update to the theme.
This issue is exactly the same for the Porto 3.2.6 theme - I will report this to the developers.
I just finished upgrading to 2.4.3. Guess what, issue still persists. Kind of an important functionality no?
Anyway, usual workaround applied, replaced track.phtml with old one, did the trick. Please note, my track.phtml is timestamped 3rd Feb 2020 LMFAO.
Hola Magento! Wakey wakey
This issue is exactly the same for the Porto 3.2.6 theme - I will report this to the developers.
@stefanskotte I'm also using Porto. Seeing the file we have to replace here is in vendor/magento, this implies that the problem comes from Magento core, as the template is not being overwritten by Porto. Hope that helps.
In 2.4.3 the issue is still there.
In 2.4.3 the issue is still there.
Looks like a possible fix MC-42758 was merged on August 10, the same date 2.4.3 was released.
The branch 2.4-develop is up-to-date with the fix, but not the 2.4.3 release branch.
I don't know much about Magento releases. Should we expect this fix to be released in a patch or in the next feature update?
Actually this issue was caused by your theme sales email htmls was located in
app/design/frontend/Foo/bar/Magento_Sales/email/*.html
Remove those or check whether they were upgraded, comparable with original ones
Preconditions (*)
Steps to reproduce (*)
Expected result (*)
Actual result (*)