Advertisement
Guest User

Untitled

a guest
Apr 18th, 2016
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. <?xml version="1.0"?>
  2. <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
  3. <event name="catalog_product_save_after">
  4. <observer name="test_name" instance="RahahaRahahaWebServiceObserverProductsaveafter" />
  5. </event>
  6. </config>
  7.  
  8. <?php
  9. namespace RahahaRahahaWebServiceObserver;
  10.  
  11. use MagentoFrameworkEventObserverInterface;
  12. use MagentoFrameworkEventObserver;
  13.  
  14. class Productsaveafter implements ObserverInterface
  15. {
  16. protected $_request;
  17. protected $_resource;
  18. protected $_scopeConfig;
  19. protected $_rahaha;
  20.  
  21. public function __construct(
  22. MagentoFrameworkAppRequestInterface $request,
  23. MagentoFrameworkAppResourceConnection $resource,
  24. MagentoFrameworkAppConfigScopeConfigInterface $scopeConfig
  25. )
  26. {
  27. $this->_request = $request;
  28. $this->_resource = $resource;
  29. $this->_scopeConfig = $scopeConfig;
  30.  
  31. $storeScope = MagentoStoreModelScopeInterface::SCOPE_STORE;
  32. $rahaha_username = $this->_scopeConfig->getValue("adminsample/rahaha_module_credentials_grp/rahaha_username", $storeScope);
  33. $rahaha_password = $this->_scopeConfig->getValue("adminsample/rahaha_module_credentials_grp/rahaha_password", $storeScope);
  34. $rahaha_api_key = $this->_scopeConfig->getValue("adminsample/rahaha_module_credentials_grp/rahaha_api_key", $storeScope);
  35. $rahaha_module_status = $this->_scopeConfig->getValue("adminsample/rahaha_module_status_grp/rahaha_module_status", $storeScope);
  36.  
  37. $rs = $this->_resource;
  38.  
  39. $this->_rahaha = new RahahaRahahaWebServiceModelRahahaRahaha($rahaha_username, $rahaha_password, $rahaha_api_key, $rahaha_module_status, $rs);
  40. }
  41.  
  42. public function execute(MagentoFrameworkEventObserver $observer)
  43. {
  44. $post_data = $this->_request->getPost()->toArray();
  45.  
  46. //save stuff here...
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement