Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update grid columns from detail page #620

Merged
merged 1 commit into from
Dec 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Model/Sales/MagentoCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,23 @@ public function getHtmlForGridColumns($orderId)
$areaObject = $this->areaList->getArea(\Magento\Framework\App\Area::AREA_ADMINHTML);
$areaObject->load(\Magento\Framework\App\Area::PART_TRANSLATE);
}
$tracks = $this->getTracksCollectionByOrderId($orderId);

return $this->getHtmlForGridColumnsByTracks($this->getTracksCollectionByOrderId($orderId));
}

/**
* @param Order\Shipment\Track[]|\Magento\Sales\Model\ResourceModel\Order\Shipment\Track\Collection $tracks
*
* @return string[]
*/
public function getHtmlForGridColumnsByTracks($tracks): array
{
$data = ['track_status' => [], 'track_number' => []];
$columnHtml = ['track_status' => '', 'track_number' => ''];

/**
* @var Order\Shipment $shipment
* @var Order\Shipment\Track $track
*/
foreach ($tracks as $track) {
// Set all Track data in array
if ($track['myparcel_status'] !== null) {
if (null !== $track['myparcel_status']) {
$data['track_status'][] = __('status_' . $track['myparcel_status']);
}
if ($track['track_number']) {
Expand Down
4 changes: 2 additions & 2 deletions Observer/NewShipment.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ private function setMagentoAndMyParcelTrack(Shipment $shipment)
*
* @throws \Exception
*/
private function updateTrackGrid($shipment)
private function updateTrackGrid($shipment): void
{
$aHtml = $this->orderCollection->getHtmlForGridColumns($shipment->getOrder()->getId());
$aHtml = $this->orderCollection->getHtmlForGridColumnsByTracks($shipment->getTracksCollection());
$shipment->getOrder()
->setData('track_status', $aHtml['track_status'])
->setData('track_number', $aHtml['track_number'])
Expand Down