Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. namespace CustomModuleBlock;
  2.  
  3. use MagentoFrameworkViewElementTemplate;
  4. use MagentoCatalogApiProductRepositoryInterface;
  5. use MagentoCatalogModelProduct;
  6.  
  7.  
  8. class ImageUploader extends MagentoCatalogBlockProductView
  9. {
  10. public function __construct(
  11. MagentoCatalogBlockProductContext $context,
  12. MagentoFrameworkUrlEncoderInterface $urlEncoder,
  13. MagentoFrameworkJsonEncoderInterface $jsonEncoder,
  14. MagentoFrameworkStdlibStringUtils $string,
  15. MagentoCatalogHelperProduct $productHelper,
  16. MagentoCatalogModelProductTypesConfigInterface $productTypeConfig,
  17. MagentoFrameworkLocaleFormatInterface $localeFormat,
  18. MagentoCustomerModelSession $customerSession,
  19. ProductRepositoryInterface $productRepository,
  20. MagentoFrameworkPricingPriceCurrencyInterface $priceCurrency,
  21. array $data = []
  22. )
  23. {
  24. parent::__construct(
  25. $context,
  26. $urlEncoder,
  27. $jsonEncoder,
  28. $string,
  29. $productHelper,
  30. $productTypeConfig,
  31. $localeFormat,
  32. $customerSession,
  33. $productRepository,
  34. $priceCurrency,
  35. $data
  36. );
  37. }
  38.  
  39. public function process()
  40. {
  41. // Return image path here to Jquery Ajax;
  42. }
  43.  
  44. protected function _toHtml()
  45. {
  46. $this->setModuleName($this->extractModuleName('MagentoCatalogBlockProductView'));
  47. return parent::_toHtml();
  48. }
  49. }
  50.  
  51. <?php $_product = $block->getProduct(); ?>
  52. <div id="personalise" class="personalise">
  53. <div class="wrapper">
  54. <h2>Personalise Your Label</h2>
  55. <!--- SOme html structure here -->
  56. </div>
  57. </div>
  58.  
  59.  
  60. <script type="text/javascript">
  61. require(['jquery'], function(jQuery){
  62. jQuery("button").on('click', function() {
  63. jQuery.ajax({
  64. type: "POST",
  65. url: "<URL_PATH_TO_CUSTOM_PROCESS_BLOCK_ACTION>"
  66. }).done(function(o) {
  67.  
  68. alert("DOne");
  69. });
  70. return false;
  71. });
  72. });
  73. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement