Skip to content

Commit

Permalink
Added debug mode for collection check + enhance debug of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sdkwebprojects committed Sep 25, 2023
1 parent 88f67c7 commit 8318ece
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 19 deletions.
10 changes: 10 additions & 0 deletions Helper/Data.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ class Data extends AbstractHelper
*/
const XML_PATH_PROBANCE_GIVEN_FLOW = 'probance/%s_flow/%s';

/**
* XML Path to DEBUG mode
*/
const XML_PATH_PROBANCE_DEBUG = 'probance/flow/debug';

/**
* @var SequenceFactory
*/
Expand Down Expand Up @@ -323,4 +328,9 @@ protected function formatSequenceValue($value)

return '-' . $value;
}

public function getDebugMode()
{
return $this->scopeConfig->getValue(self::XML_PATH_PROBANCE_DEBUG);
}
}
47 changes: 30 additions & 17 deletions Model/Export/AbstractFlow.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,23 +162,36 @@ public function export()
$this->probanceHelper->getFlowFormatValue('enclosure')
);

foreach ($this->getArrayCollection() as $collection) {
$object = $collection['object'];
$count = (isset($collection['count']) ? $collection['count'] : $object->count());

if ($this->progressBar) {
$this->progressBar->setMessage('Starting '.$collection['callback'].' export...', 'status');
$this->progressBar->start($count ?: 1);
}

$this->iterator->walk($object->getSelect(), [[$this, $collection['callback']]]);

if (count($this->errors) > 0) {
$this->addLog(serialize($this->errors));
}

if ($this->progressBar) {
$this->progressBar->setMessage($filename . ' was created.', 'status');
$debug = $this->probanceHelper->getDebugMode();

foreach ($this->getArrayCollection() as $collection)
{
try {
$object = $collection['object'];
$count = (isset($collection['count']) ? $collection['count'] : $object->count());
if ($debug) {
$this->addLog('Flow count elements is :'.$count.' // Using this request : '.$collection['object']->getSelect().'');
}

if ($this->progressBar) {
$this->progressBar->setMessage('Starting '.$collection['callback'].' export...', 'status');
$this->progressBar->start($count ?: 1);
}

$this->iterator->walk($object->getSelect(), [[$this, $collection['callback']]]);

if (count($this->errors) > 0) {
$this->addLog(serialize($this->errors));
}

if ($this->progressBar) {
$this->progressBar->setMessage($filename . ' was created.', 'status');
}
} catch (\Exception $e) {
$this->addLog(serialize([
'message' => $e->getMessage(),
'trace' => $e->getTraceAsString(),
]));
}
}

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": "probance/m2connector",
"description": "Probance module for Magento 2",
"type": "magento2-module",
"version": "1.2.7",
"version": "1.2.8",
"license": [
"OSL-3.0",
"AFL-3.0"
Expand Down
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@
<source_model>Magento\Config\Model\Config\Source\Locale\Timezone</source_model>
<backend_model>Magento\Config\Model\Config\Backend\Locale\Timezone</backend_model>
</field>
<field id="debug" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Enable debug mode</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
<group id="catalog_flow" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
<label>Catalog flow</label>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?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="Probance_M2connector" setup_version="1.2.7">
<module name="Probance_M2connector" setup_version="1.2.8">
<sequence>
<module name="Magento_SalesRule"/>
<module name="Magento_Sales"/>
Expand Down

0 comments on commit 8318ece

Please sign in to comment.