Grids.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Backend\Block\Dashboard;
  7. /**
  8. * Adminhtml dashboard bottom tabs
  9. *
  10. * @author Magento Core Team <core@magentocommerce.com>
  11. */
  12. class Grids extends \Magento\Backend\Block\Widget\Tabs
  13. {
  14. /**
  15. * @var string
  16. */
  17. protected $_template = 'Magento_Backend::widget/tabshoriz.phtml';
  18. /**
  19. * @return void
  20. */
  21. protected function _construct()
  22. {
  23. parent::_construct();
  24. $this->setId('grid_tab');
  25. $this->setDestElementId('grid_tab_content');
  26. }
  27. /**
  28. * Prepare layout for dashboard bottom tabs
  29. *
  30. * To load block statically:
  31. * 1) content must be generated
  32. * 2) url should not be specified
  33. * 3) class should not be 'ajax'
  34. * To load with ajax:
  35. * 1) do not load content
  36. * 2) specify url (BE CAREFUL)
  37. * 3) specify class 'ajax'
  38. *
  39. * @return $this
  40. */
  41. protected function _prepareLayout()
  42. {
  43. // load this active tab statically
  44. $this->addTab(
  45. 'ordered_products',
  46. [
  47. 'label' => __('Bestsellers'),
  48. 'content' => $this->getLayout()->createBlock(
  49. \Magento\Backend\Block\Dashboard\Tab\Products\Ordered::class
  50. )->toHtml(),
  51. 'active' => true
  52. ]
  53. );
  54. // load other tabs with ajax
  55. $this->addTab(
  56. 'reviewed_products',
  57. [
  58. 'label' => __('Most Viewed Products'),
  59. 'url' => $this->getUrl('adminhtml/*/productsViewed', ['_current' => true]),
  60. 'class' => 'ajax'
  61. ]
  62. );
  63. $this->addTab(
  64. 'new_customers',
  65. [
  66. 'label' => __('New Customers'),
  67. 'url' => $this->getUrl('adminhtml/*/customersNewest', ['_current' => true]),
  68. 'class' => 'ajax'
  69. ]
  70. );
  71. $this->addTab(
  72. 'customers',
  73. [
  74. 'label' => __('Customers'),
  75. 'url' => $this->getUrl('adminhtml/*/customersMost', ['_current' => true]),
  76. 'class' => 'ajax'
  77. ]
  78. );
  79. return parent::_prepareLayout();
  80. }
  81. }