Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace CustomModuleBlock;
- use MagentoFrameworkViewElementTemplate;
- use MagentoCatalogApiProductRepositoryInterface;
- use MagentoCatalogModelProduct;
- class ImageUploader extends MagentoCatalogBlockProductView
- {
- public function __construct(
- MagentoCatalogBlockProductContext $context,
- MagentoFrameworkUrlEncoderInterface $urlEncoder,
- MagentoFrameworkJsonEncoderInterface $jsonEncoder,
- MagentoFrameworkStdlibStringUtils $string,
- MagentoCatalogHelperProduct $productHelper,
- MagentoCatalogModelProductTypesConfigInterface $productTypeConfig,
- MagentoFrameworkLocaleFormatInterface $localeFormat,
- MagentoCustomerModelSession $customerSession,
- ProductRepositoryInterface $productRepository,
- MagentoFrameworkPricingPriceCurrencyInterface $priceCurrency,
- array $data = []
- )
- {
- parent::__construct(
- $context,
- $urlEncoder,
- $jsonEncoder,
- $string,
- $productHelper,
- $productTypeConfig,
- $localeFormat,
- $customerSession,
- $productRepository,
- $priceCurrency,
- $data
- );
- }
- public function process()
- {
- // Return image path here to Jquery Ajax;
- }
- protected function _toHtml()
- {
- $this->setModuleName($this->extractModuleName('MagentoCatalogBlockProductView'));
- return parent::_toHtml();
- }
- }
- <?php $_product = $block->getProduct(); ?>
- <div id="personalise" class="personalise">
- <div class="wrapper">
- <h2>Personalise Your Label</h2>
- <!--- SOme html structure here -->
- </div>
- </div>
- <script type="text/javascript">
- require(['jquery'], function(jQuery){
- jQuery("button").on('click', function() {
- jQuery.ajax({
- type: "POST",
- url: "<URL_PATH_TO_CUSTOM_PROCESS_BLOCK_ACTION>"
- }).done(function(o) {
- alert("DOne");
- });
- return false;
- });
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement