Resetorders.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Dotdigitalgroup\Email\Block\Adminhtml\Config\Developer;
  3. class Resetorders extends \Magento\Config\Block\System\Config\Form\Field
  4. {
  5. /**
  6. * @var string
  7. */
  8. public $buttonLabel = 'Run Now';
  9. /**
  10. * @param string $buttonLabel
  11. *
  12. * @return $this
  13. */
  14. public function setButtonLabel($buttonLabel)
  15. {
  16. $this->buttonLabel = $buttonLabel;
  17. return $this;
  18. }
  19. /**
  20. * Get the button and scripts contents.
  21. *
  22. * @param \Magento\Framework\Data\Form\Element\AbstractElement $element
  23. *
  24. * @return string
  25. */
  26. public function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
  27. {
  28. $query = [
  29. '_query' => [
  30. 'from' => '',
  31. 'to' => '',
  32. 'tp' => ''
  33. ]
  34. ];
  35. $url = $this->_urlBuilder->getUrl('dotdigitalgroup_email/run/ordersreset', $query);
  36. return $this->getLayout()
  37. ->createBlock(\Magento\Backend\Block\Widget\Button::class)
  38. ->setType('button')
  39. ->setId($element->getId())
  40. ->setLabel($this->buttonLabel)
  41. ->setOnClick("window.location.href='" . $url . "'")
  42. ->toHtml();
  43. }
  44. }