Skip to content

Commit

Permalink
Merge pull request #58 from feedaty/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
altravista committed May 14, 2023
2 parents 853be97 + 5b28296 commit 2857d30
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 84 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,13 @@

#### RELASE NOTES


### V2.10.3

* Fixed Bugs
* PHP 8.2 compatibility


### V2.10.1
* Features:
* Debug Mode
Expand Down
44 changes: 23 additions & 21 deletions Controller/Adminhtml/Index/Index.php
Expand Up @@ -35,7 +35,7 @@ class Index extends \Magento\Backend\App\Action
/**
* @var ConfigRules
*/
protected $_configRules;
protected $configRules;

/**
* @var \Magento\Store\Model\StoreManagerInterface
Expand All @@ -61,13 +61,15 @@ class Index extends \Magento\Backend\App\Action
/**
* @var LoggerInterface
*/
protected $_logger;
protected $logger;


/**
* @var Url
*/
private $url;
private Context $context;
private Csv $csv;

/**
* @param Context $context
Expand Down Expand Up @@ -97,16 +99,16 @@ public function __construct(
)
{
parent::__construct($context);
$this->_scopeConfig = $scopeConfig;
$this->_storeManager = $storeManager;
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->resultPageFactory = $resultPageFactory;
$this->_objectManager = $objectmanager;
$this->_csv = $csv;
$this->_directoryList = $directoryList;
$this->objectManager = $objectmanager;
$this->csv = $csv;
$this->directoryList = $directoryList;
$this->ordersHelper = $ordersHelper;
$this->context = $context;
$this->_configRules = $configRules;
$this->_logger = $logger;
$this->configRules = $configRules;
$this->logger = $logger;
$this->url = $url;
}

Expand All @@ -119,33 +121,33 @@ public function execute()

# INIT FIELDS

$storeId = (int)$this->_request->getParam('store', 0);
$storeId = (int)$this->request->getParam('store', 0);

/**
* Get Feedaty Order options Status
*/
$orderStatus = $this->_configRules->getSendOrderStatus($storeId);
$orderStatus = $this->configRules->getSendOrderStatus($storeId);

/**
* Get Debug Mode
*/
$debugMode = $this->_configRules->getDebugModeEnabled($storeId);
$debugMode = $this->configRules->getDebugModeEnabled($storeId);

/**
* Get Data Range Options
*/
$exportDateFrom = $this->_configRules->getExportOrdersFrom($storeId);
$exportDateTo = $this->_configRules->getExportOrdersTo($storeId);
$exportDateFrom = $this->configRules->getExportOrdersFrom($storeId);
$exportDateTo = $this->configRules->getExportOrdersTo($storeId);
$last4months = date('Y-m-d', strtotime("-4 months"));
$now = date('Y-m-d', strtotime("+1 days"));
$from = $exportDateFrom != '' ? $exportDateFrom : $last4months;
$to = $exportDateTo != '' ? $exportDateTo : $now;

if ($debugMode === "1") {
$this->_logger->info("Feedaty | Export Orders From Admin Panel | Store ID: " . $storeId . "Order Status " . $orderStatus . " | date: " . date('Y-m-d H:i:s'));
$this->logger->info("Feedaty | Export Orders From Admin Panel | Store ID: " . $storeId . "Order Status " . $orderStatus . " | date: " . date('Y-m-d H:i:s'));
}

$dirPath = $this->_directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);
$dirPath = $this->directoryList->getPath(\Magento\Framework\App\Filesystem\DirectoryList::VAR_DIR);
$outputFile = $dirPath . "/tmp/FeedatyOrderExport_" . date('Ymd_His') . ".csv";

if (!is_dir($dirPath))
Expand All @@ -159,8 +161,8 @@ public function execute()

$heading = ["Order ID", "UserID", "E-mail", "Date", "Product ID", "Extra", "Product Url", "Product Image", "EAN", "Platform"];

$this->_csv->setDelimiter($delimiter);
$this->_csv->setEnclosure($enclosure);
$this->csv->setDelimiter($delimiter);
$this->csv->setEnclosure($enclosure);

$data[] = $heading;

Expand Down Expand Up @@ -194,12 +196,12 @@ public function execute()
$options = $item->getProductOptions();
if(!empty($options['info_buyRequest'])) {
if(!empty($options['super_product_config']["product_id"])) {
$productUrl = $this->_storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$options['super_product_config']["product_id"].'/?___store='.$storeId;
$productUrl = $this->storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$options['super_product_config']["product_id"].'/?___store='.$storeId;
}
}
}
else{
$productUrl = $this->_storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$productId.'/?___store='.$storeId;
$productUrl = $this->storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$productId.'/?___store='.$storeId;
}
}

Expand Down Expand Up @@ -228,7 +230,7 @@ public function execute()

# WRITE TO CSV FILE

$this->_csv->saveData($outputFile, $data);
$this->csv->saveData($outputFile, $data);
$this->downloadCsv($outputFile);

# END WRITE TO CSV
Expand Down
6 changes: 3 additions & 3 deletions Cron/Orders.php
Expand Up @@ -71,7 +71,7 @@ public function __construct(
$this->dataHelper = $dataHelper;
$this->_configRules = $configRules;
$this->url = $url;
$this->_storeManager = $storeManager;
$this->storeManager = $storeManager;
}

/**
Expand Down Expand Up @@ -158,12 +158,12 @@ public function execute()
$options = $item->getProductOptions();
if(!empty($options['info_buyRequest'])) {
if(!empty($options['super_product_config']["product_id"])) {
$productUrl = $this->_storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$options['super_product_config']["product_id"].'/?___store='.$storeId;
$productUrl = $this->storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$options['super_product_config']["product_id"].'/?___store='.$storeId;
}
}
}
else{
$productUrl = $this->_storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$productId.'/?___store='.$storeId;
$productUrl = $this->storeManager->getStore($storeId)->getBaseUrl() . 'catalog/product/view/id/'.$productId.'/?___store='.$storeId;
}

$ean = $this->ordersHelper->getProductEan($storeId, $item);
Expand Down
4 changes: 2 additions & 2 deletions Helper/ConfigRules.php
Expand Up @@ -49,8 +49,8 @@ public function getExportConfig($data, $storeId = null){
}


public function getSnippetConfig($data){
return $this->helperConfigSetting->getSnippetConfig($data);
public function getSnippetConfig($data, $storeId){
return $this->helperConfigSetting->getSnippetConfig($data, $storeId);
}

/**
Expand Down
32 changes: 2 additions & 30 deletions Helper/Data.php
Expand Up @@ -26,7 +26,7 @@ public function __construct(
\Magento\Framework\Module\ModuleListInterface $moduleList,
\Magento\Store\Model\StoreManagerInterface $storeManager
) {
$this->_moduleList = $moduleList;
$this->moduleList = $moduleList;
$this->storeManager = $storeManager;
parent::__construct($context);
}
Expand All @@ -49,37 +49,9 @@ public function getAllStoresIds()

public function getExtensionVersion() {
$moduleCode = 'Feedaty_Badge';
$moduleInfo = $this->_moduleList->getOne($moduleCode);
$moduleInfo = $this->moduleList->getOne($moduleCode);
return $moduleInfo['setup_version'];
}

/**
* Function Feedaty Debug - Save debug infoes in MageBasePath/var/log/feedaty.log
* @param $message - string - the debug message
* @param $severity - string - the message severity
*/
public function feedatyDebug($message, $severity) {
$message = json_encode($message);
$fdwriter = new \Zend\Log\Writer\Stream(BP . '/var/log/feedaty.log');
$fdlogger = new \Zend\Log\Logger();
$fdlogger->addWriter($fdwriter);
$fdlogger->info("\n".$severity."\n".$message."\n");

}

/**
* Returns system configuration value
*
* @param $key
* @param null $store
* @return mixed
*/
public function getConfigurationValue($key, $store = null)
{
return $this->scopeConfig->getValue(
'example_section/' . $key,
\Magento\Store\Model\ScopeInterface::SCOPE_STORE,
$store
);
}
}
9 changes: 3 additions & 6 deletions Helper/Reviews.php
Expand Up @@ -2,7 +2,6 @@

namespace Feedaty\Badge\Helper;

use Feedaty\Badge\Helper\ConfigRules;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Store\Api\StoreRepositoryInterface;
use Magento\Review\Model\ResourceModel\Review\CollectionFactory;
Expand Down Expand Up @@ -125,21 +124,19 @@ public function getStoreViewIdByOrder($orderId, $storeId)
$forceDefaultStore = $this->_helperConfigRules->getReviewForceDefaultStore($storeId);

if($forceDefaultStore === "1"){
$defaultStore = $this->_helperConfigRules->getReviewDefaultStore($storeId);
return $defaultStore;
return $this->_helperConfigRules->getReviewDefaultStore($storeId);
}
else{
$order = null;
try {
$order = $this->_orderRepository->get($orderId);
}
catch (\Exception $e) {
$this->_logger->info("Feedaty | Error : order id does not exist " . $orderId . " Error message". $e->getMessage());
$this->_logger->error("Feedaty | Order id does not exist " . $orderId . " Message". $e->getMessage());
}

if (!is_null($order)) {
$websiteId = $order->getStore()->getWebsiteId();
return $websiteId;
return $order->getStore()->getWebsiteId();
}

return null;
Expand Down
25 changes: 18 additions & 7 deletions Helper/WidgetHelper.php
Expand Up @@ -25,19 +25,30 @@ class WidgetHelper extends \Magento\Framework\App\Helper\AbstractHelper
* Constructor
*
*/
private WebService $service;
private Http $request;
private StoreManagerInterface $storeManager;

/**
* @param ScopeConfigInterface $scopeConfig
* @param StoreManagerInterface $storeManager
* @param Data $dataHelper
* @param Http $request
* @param WebService $service
*/
public function __construct(
ScopeConfigInterface $scopeConfig,
StoreManagerInterface $storeManager,
DataHelp $dataHelper,
Http $request,
WebService $fdservice
WebService $service
)
{
$this->scopeConfig = $scopeConfig;
$this->storeManager = $storeManager;
$this->_dataHelper = $dataHelper;
$this->_request = $request;
$this->_fdservice = $fdservice;
$this->dataHelper = $dataHelper;
$this->request = $request;
$this->service = $service;
}

/**
Expand All @@ -51,11 +62,11 @@ public function badgeData($type)

$store_scope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;

$store = $this->storeManager->getStore($this->_request->getParam('store',0));
$store = $this->storeManager->getStore($this->request->getParam('store',0));

$merchant_code = $store->getConfig('feedaty_global/feedaty_preferences/feedaty_code');

if ($this->_request->getParam('store', 0) == 0) {
if ($this->request->getParam('store', 0) == 0) {

$merchant_code = $this->scopeConfig->getValue('feedaty_global/feedaty_preferences/feedaty_code', $store_scope);

Expand All @@ -67,7 +78,7 @@ public function badgeData($type)

}

$dataObject = $this->_fdservice->getFeedatyData($merchant_code);
$dataObject = $this->service->getFeedatyData($merchant_code);

$data = $dataObject[$type]['variants'];

Expand Down
6 changes: 4 additions & 2 deletions Model/Config/Source/OrderStatuses.php
Expand Up @@ -7,14 +7,16 @@

class OrderStatuses implements OptionSourceInterface
{
protected $orderConfig;


/**
* Constructor
*
*/
public function __construct(Config $orderConfig)
{
$this->_orderConfig = $orderConfig;
$this->orderConfig = $orderConfig;
}

/**
Expand All @@ -23,7 +25,7 @@ public function __construct(Config $orderConfig)
*/
public function toOptionArray()
{
$statuses = $this->_orderConfig->getStatuses();
$statuses = $this->orderConfig->getStatuses();

$order_array = array();
foreach($statuses as $k=>$label)
Expand Down

0 comments on commit 2857d30

Please sign in to comment.