· 7 years ago · Jan 11, 2019, 09:32 PM
1<?php
2namespace UnoMercadoLibreControllerAdminhtmlAction;
3
4use MagentoBackendAppAction;
5
6class publicar extends Action {
7 protected $_session;
8
9 protected $_filesystem;
10 protected $_directoryList;
11
12 /**
13 * @param ActionContext $context
14 */
15 public function __construct(
16 ActionContext $context,
17 MagentoFrameworkFilesystemDirectoryList $directoryList,
18 MagentoFrameworkFilesystem $filesystem,
19 MagentoCustomerModelSession $session
20 ) {
21 parent::__construct($context);
22 $this->_directoryList = $directoryList;
23 $this->_filesystem = $filesystem;
24 $this->_session = $session;
25 }
26
27 /**
28 * {@inheritdoc}
29 */
30 protected function _isAllowed() {
31 return $this->_authorization->isAllowed('Uno_MercadoLibre::action_publicar');
32 }
33
34 /**
35 * Publicar action
36 *
37 * @return MagentoFrameworkControllerResultInterface
38 */
39 public function execute() {
40 $appId = '123';
41 $secretKey = 'abcdefghijkl';
42 $redirectURI = 'https://example.mx';
43 $siteId = 'MLM';
44
45 //$path = $this->_directoryList->getPath('lib_web');
46 //echo "PATH " . $path.'/Meli/Meli.php';
47 //require_once($path.'/Meli/Meli.php');
48
49 //$libPath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::LIB)->getAbsolutePath();
50
51 $mediapath = $this->_filesystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::APP)->getAbsolutePath();
52 $modulePath = $mediapath.'code/Uno/MecadoLibre/lib/Meli/Meli.php';
53
54 echo $modulePath;
55
56 require_once($modulePath);
57
58 $meli = new Meli($appId, $secretKey);
59 $params = array();
60
61 $url = '/sites/' . $siteId;
62
63 $result = $meli->get($url, $params);
64
65 echo '<pre>';
66 print_r($result);
67 echo '</pre>';
68 die();
69 }
70}
71
72?>