Skip to content

Commit

Permalink
Merge pull request #11 from Returnless-com/feat/add-search-priority
Browse files Browse the repository at this point in the history
Add search priority for Marketplace and Magento orders
  • Loading branch information
chris-returnless authored Sep 5, 2023
2 parents 46cefc7 + 7257cd7 commit e812b41
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 6 deletions.
16 changes: 12 additions & 4 deletions Model/Api/OrderInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,27 @@ public function getOrderInfoReturnless($incrementId)
$this->logger->debug('[RET_ORDER_INFO] Increment Id', [$incrementId]);

try {
$order = $this->retHelper->searchOrder($incrementId);
if (!$order->getId() && $this->config->getMarketplaceSearchEnabled()) {
/** @var \Returnless\Connector\Model\PartnersSourceAdapter $partnersSourceAdapter */
if ($this->config->getMarketplaceSearchEnabled() && $this->config->getSearchPriority() === 'marketplace') {
$partnersSourceAdapter = ObjectManager::getInstance()->get('Returnless\Connector\Model\PartnersSourceAdapter');
$order = $partnersSourceAdapter->getOrderByMarketplace($incrementId);
if (!$order->getId()) {
$order = $this->retHelper->searchOrder($incrementId);
}
} else {
$order = $this->retHelper->searchOrder($incrementId);
if (!$order->getId() && $this->config->getMarketplaceSearchEnabled()) {
/** @var \Returnless\Connector\Model\PartnersSourceAdapter $partnersSourceAdapter */
$partnersSourceAdapter = ObjectManager::getInstance()->get('Returnless\Connector\Model\PartnersSourceAdapter');
$order = $partnersSourceAdapter->getOrderByMarketplace($incrementId);
}
}


$orderInfo['id'] = $order->getIncrementId();
$orderInfo['order_id'] = $order->getEntityId();
$orderInfo['create_at']['value'] = $order->getCreatedAt();

$payment = $order->getPayment();
$methodTitle = '';
if($payment) {
$method = $payment->getMethodInstance();
$methodTitle = $method->getTitle();
Expand Down
18 changes: 18 additions & 0 deletions Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ class Config
*/
const CONFIG_GENERATION_TYPE = 'returnless_connector/general/generation_type';

/**
* const Order search priority
*/
const CONFIG_MARKETPLACE_SEARCH_PRIORITY = 'returnless_connector/marketplace_orders/search_priority';

/**
* Config constructor.
*
Expand Down Expand Up @@ -187,4 +192,17 @@ public function getGenerationType($store = null)

return $generationType;
}

/**
* @param $store
* @return string
*/
public function getSearchPriority($store = null)
{
return (string) $this->scopeConfig->getValue(
self::CONFIG_MARKETPLACE_SEARCH_PRIORITY,
ScopeInterface::SCOPE_STORE,
$store
);
}
}
30 changes: 30 additions & 0 deletions Model/Config/Source/SearchPriority.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace Returnless\Connector\Model\Config\Source;

use Magento\Framework\Option\ArrayInterface;

/**
* Class IntegrationPartner
* @package Returnless\Connector\Model\Config
*/
class SearchPriority implements ArrayInterface
{
/**
* @return array
*/
public function toOptionArray()
{
return
[
[
'value' => 'magento',
'label' => __('Magento orders, Marketplace orders')
],
[
'value' => 'marketplace',
'label' => __('Marketplace orders, Magento orders')
]
];
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@
"OSL-3.0",
"AFL-3.0"
],
"version": "1.2.7"
"version": "1.2.8"
}
4 changes: 4 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@
<label>Integration Partner</label>
<source_model>Returnless\Connector\Model\Config\Source\IntegrationPartner</source_model>
</field>
<field id="search_priority" translate="label" type="select" sortOrder="30" showInDefault="1" showInStore="1" showInWebsite="1">
<label>Search priority</label>
<source_model>Returnless\Connector\Model\Config\Source\SearchPriority</source_model>
</field>
</group>
</section>
</system>
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?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="Returnless_Connector" setup_version="1.2.7">
<module name="Returnless_Connector" setup_version="1.2.8">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down

0 comments on commit e812b41

Please sign in to comment.