0

i want to get redorer url of order Id in magento , please help with you to do same , unable to find any soluiton to this issue.

enter image description here

0

In order to get it on frontend use below code

<?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order->getEntityId())) : ?>
    <a href="#" data-post='<?php /* @escapeNotVerified */ echo
    $this->helper(\Magento\Framework\Data\Helper\PostHelper::class)
        ->getPostData($block->getReorderUrl($_order))
    ?>' class="action order">
        <span><?= /* @escapeNotVerified */ __('Reorder') ?></span>
    </a>
<?php endif ?>

In backend it is coming from below function

vendor/magento/module-sales/Block/Adminhtml/Order/View.php

if ($this->_isAllowedAction(
    'Magento_Sales::reorder'
) && $this->_reorderHelper->isAllowed(
    $order->getStore()
) && $order->canReorderIgnoreSalable()
) {
    $this->addButton(
        'order_reorder',
        [
            'label' => __('Reorder'),
            'onclick' => 'setLocation(\'' . $this->getReorderUrl() . '\')',
            'class' => 'reorder'
        ]
    );
}

and

/**
 * Reorder URL getter
 *
 * @return string
 */
public function getReorderUrl()
{
    return $this->getUrl('sales/order_create/reorder');
}

I hope it will help you. Thanks!

1
  • i tried below code but it did not work for amdin $order = $this->orderFactory->create()->load($this->getValue()); $b = $order->getReorderUrl(); Apr 3 '21 at 11:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.