Skip to content

Commit

Permalink
Ec 165 (#46)
Browse files Browse the repository at this point in the history
added logs for orders details
  • Loading branch information
prafullcybage authored May 15, 2023
1 parent d1c3a6a commit c37abab
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 9 deletions.
2 changes: 1 addition & 1 deletion app/code/Ometria/AbandonedCarts/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_AbandonedCarts" setup_version="2.6.1"/>
<module name="Ometria_AbandonedCarts" setup_version="2.6.2"/>
</config>
23 changes: 18 additions & 5 deletions app/code/Ometria/Api/Controller/V1/Orders.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Ometria\Api\Helper\Format\V1\Orders as Helper;
use Ometria\Api\Helper\Order\IsValid as OrderIsValidHelper;
use Ometria\Api\Helper\Service\Filterable\Service as FilterableService;
use Ometria\Core\Helper\Config;

class Orders extends Base
{
Expand Down Expand Up @@ -42,6 +43,9 @@ class Orders extends Base
/** @var WeeeHelper */
private $weeeHelper;

/** @var Config */
protected $helperConfig;

/**
* @param Context $context
* @param JsonFactory $resultJsonFactory
Expand All @@ -52,6 +56,7 @@ class Orders extends Base
* @param OrderCollectionFactory $orderCollectionFactory
* @param OrderIsValidHelper $orderValidTester
* @param WeeeHelper $weeeHelper
* @param Config $helperConfig
*/
public function __construct(
Context $context,
Expand All @@ -62,7 +67,8 @@ public function __construct(
OrderAddressFactory $orderAddressFactory,
OrderCollectionFactory $orderCollectionFactory,
OrderIsValidHelper $orderValidTester,
WeeeHelper $weeeHelper
WeeeHelper $weeeHelper,
Config $helperConfig
) {
parent::__construct($context);

Expand All @@ -74,6 +80,7 @@ public function __construct(
$this->orderCollectionFactory = $orderCollectionFactory;
$this->orderValidTester = $orderValidTester;
$this->weeeHelper = $weeeHelper;
$this->helperConfig = $helperConfig;
}

/**
Expand All @@ -88,7 +95,6 @@ public function execute()
} else {
$data = $this->getItemsData($items);
}

return $this->resultJsonFactory->create()->setData($data);
}

Expand Down Expand Up @@ -127,7 +133,16 @@ private function getItemsData(array $items)
$items = $this->addAddresses($items);
$items = $this->addLineItems($items);
$items = $this->replaceIdWithIncrementId($items);

// Getting Show Logs value
$statusLogValue = $this->helperConfig->getLogConfig();
if ($statusLogValue){
$writer = new \Zend_Log_Writer_Stream(BP . '/var/log/order-details.log');
$logger = new \Zend_Log();
$logger->addWriter($writer);
$logger->info("Order details -----------------");
$logger->info(print_r($items, true));
$logger->info("-------------------------------");
}
return $items;
}

Expand Down Expand Up @@ -197,7 +212,6 @@ private function formatItems(array $items)

$items[$key] = $new;
}

return $items;
}

Expand Down Expand Up @@ -384,7 +398,6 @@ private function addLineItems(array $items)
$item['lineitems'] = $newLineItems;
$items[$key] = $item;
}

return $items;
}

Expand Down
2 changes: 1 addition & 1 deletion app/code/Ometria/Api/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Api" setup_version="2.6.1"/>
<module name="Ometria_Api" setup_version="2.6.2"/>
</config>
10 changes: 10 additions & 0 deletions app/code/Ometria/Core/Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,14 @@ public function getCookiebotClass()
{
return (string) $this->coreHelperMageConfig->get('ometria/advanced/cookiebot_classification');
}

/**
* @param null
* @return string
*/
public function getLogConfig()
{
$statusLogValue = $this->scopeConfig->getValue('ometria/advanced/show_log');
return $statusLogValue;
}
}
5 changes: 5 additions & 0 deletions app/code/Ometria/Core/etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@
<field id="unique_id" translate="label" type="Ometria\Core\Data\Form\Element\Text\Disabled" sortOrder="110" showInDefault="1" showInWebsite="0" showInStore="0">
<label>Unique Magento ID</label>
<comment>This will be auto-generated by the extension. Do not change.</comment>
</field>
<field id="show_log" translate="label comment" type="select" sortOrder="120" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<label>Show Logs</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[If Yes, this allows for the select of a field to show logs on order details.]]></comment>
</field>
</group>
</section>
Expand Down
2 changes: 1 addition & 1 deletion app/code/Ometria/Core/etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Ometria_Core" setup_version="2.6.1"/>
<module name="Ometria_Core" setup_version="2.6.2"/>
</config>
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ometria/magento2",
"type": "magento2-module",
"version": "2.6.1",
"version": "2.6.2",
"description": "Dev composer package for Ometria Extension",
"authors": [
{
Expand Down

0 comments on commit c37abab

Please sign in to comment.