Skip to content

Commit

Permalink
Changed path of fallback tables
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrestani committed Sep 25, 2018
1 parent 9e4fc3e commit 6def40e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions Helper/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,14 @@ public function getContingencyValues ($postData)

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$dir = $objectManager->get('Magento\Framework\App\Filesystem\DirectoryList');
$mediaPath = $dir->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
$varPath = $dir->getPath(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);

$intelipostMediaPath = $mediaPath . DIRECTORY_SEPARATOR . 'intelipost';
$intelipostVarPath = $varPath . DIRECTORY_SEPARATOR . 'intelipost';

/*
* calculate State Codification
*/
$stateFile = $intelipostMediaPath . DIRECTORY_SEPARATOR . 'state_codification.json';
$stateFile = $intelipostVarPath . DIRECTORY_SEPARATOR . 'state_codification.json';
$stateContent = json_decode (file_get_contents ($stateFile), true);

$stateCode = null;
Expand All @@ -146,7 +146,7 @@ public function getContingencyValues ($postData)
* calculate Contingency Table
*/
$contingencyTable = $this->_scopeConfig->getValue ('carriers/intelipost/contingency_table');
$tableFile = $intelipostMediaPath . DIRECTORY_SEPARATOR . $contingencyTable;
$tableFile = $intelipostVarPath . DIRECTORY_SEPARATOR . $contingencyTable;

$tableContent = json_decode (file_get_contents ($tableFile), true);

Expand Down
10 changes: 5 additions & 5 deletions Model/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,24 @@ public function import($tableName)
{
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$dir = $objectManager->get('Magento\Framework\App\Filesystem\DirectoryList');
$mediaPath = $dir->getPath(\Magento\Framework\App\Filesystem\DirectoryList::MEDIA);
$varPath = $dir->getPath(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);

$fileName = strpos ($tableName, '.json') !== false ? $tableName : $tableName . '.json';
$data = $this->curl_get_contents (self::FALLBACK_URL . $fileName);

if ($data && strcmp ($data, 'Not Found'))
{
$intelipostMediaPath = $mediaPath . DIRECTORY_SEPARATOR . 'intelipost';
if (!is_dir ($intelipostMediaPath)) mkdir ($intelipostMediaPath, 0777, true);
$intelipostVarPath = $varPath . DIRECTORY_SEPARATOR . 'intelipost';
if (!is_dir ($intelipostVarPath)) mkdir ($intelipostVarPath, 0755, true);

$filePath = $intelipostMediaPath . DIRECTORY_SEPARATOR . $fileName;
$filePath = $intelipostVarPath . DIRECTORY_SEPARATOR . $fileName;
file_put_contents ($filePath, $data);

if (strcmp ($fileName, 'state_codification'))
{
$data = $this->curl_get_contents(self::FALLBACK_URL . 'state_codification.json');

$filePath = $intelipostMediaPath . DIRECTORY_SEPARATOR . 'state_codification.json';
$filePath = $intelipostVarPath . DIRECTORY_SEPARATOR . 'state_codification.json';
file_put_contents ($filePath, $data);
}
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "intelipost/magento2-quote",
"description": "Intelipost Quote",
"type": "magento2-module",
"version": "1.3.4",
"version": "1.3.5",
"authors": [
{
"name": "Intelipost",
Expand Down

0 comments on commit 6def40e

Please sign in to comment.