Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. public function execute()
  2. {
  3. if (!$this->session->isLoggedIn())
  4. {
  5. $resultRedirect = $this->resultRedirectFactory->create();
  6. $resultRedirect->setPath('customer/account/login');
  7. return $resultRedirect;
  8. }
  9. else
  10. {
  11. $resultPage = $this->resultPageFactory->create();
  12. $resultPage->getConfig()->getTitle()->set(__('My Wallet'));
  13. return $resultPage;
  14.  
  15. $vat_exempt_name = $this->getRequest()->getPost('vat_exempt_name');
  16.  
  17. //.............To Create Product...........//
  18.  
  19. $objectManager = MagentoFrameworkAppObjectManager::getInstance(); // instance of object manager
  20. $product = $objectManager->create('MagentoCatalogModelProduct');
  21. $product->setSku('my-sku28'); // Set your sku here
  22. $product->setName('Sample Simple Product28'); // Name of Product
  23. $product->setAttributeSetId(4); // Attribute set id
  24. $product->setStatus(1); // Status on product enabled/ disabled 1/0
  25. $product->setWebsiteIds(array(1));
  26. $product->setWeight(10); // weight of product
  27. $product->setVisibility(4); // visibilty of product (catalog / search / catalog, search / Not visible individually)
  28. $product->setTaxClassId(0); // Tax class id
  29. $product->setTypeId('simple'); // type of product (simple/virtual/downloadable/configurable)
  30. $product->setPrice($vat_exempt_name); // price of product
  31. $product->setStockData(
  32. array(
  33. 'use_config_manage_stock' => 0,
  34. 'manage_stock' => 1,
  35. 'is_in_stock' => 1,
  36. 'qty' => 99999
  37. )
  38. );
  39. $product = $product->save();
  40. }
  41. }
  42.  
  43. <table>
  44. <tr>
  45. <th>Enter Amount to be Added in wallet (USD)</th>
  46. </tr>
  47. <tr>
  48. <td><input type="text" class="input-text watch-keyup" id="vat_exempt_name" name="vat_exempt_name" value="200"></td>
  49. </tr>
  50. <tr>
  51. <td><button type="button">Add Money to Wallet</button></td>
  52. </tr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement