Skip to content

Commit 4bd6e19

Browse files
authored
Adding a config function to check for ShipStation installation (#630)
* Adding a config function to check for ShipStation installation * Adding a catch block to ensure the function doesn't throw for missing shipstation config.xml path
1 parent 88f6e45 commit 4bd6e19

File tree

1 file changed

+18
-0
lines changed
  • app/code/Meta/BusinessExtension/Model/System

1 file changed

+18
-0
lines changed

app/code/Meta/BusinessExtension/Model/System/Config.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class Config
4141
private const VERSION_CACHE_KEY = 'meta-business-extension-version';
4242
private const EXTENSION_PACKAGE_NAME = 'meta/meta-for-magento2';
4343

44+
private const XML_PATH_AUCTANE_API_ACTIVE = 'carriers/shipstation/active';
4445
private const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_ACTIVE = 'facebook/business_extension/active';
4546
public const XML_PATH_FACEBOOK_BUSINESS_EXTENSION_INSTALLED = 'facebook/business_extension/installed';
4647

@@ -480,6 +481,23 @@ public function getFulfillmentAddress($scopeId = null, $scope = ScopeInterface::
480481
return $address;
481482
}
482483

484+
/**
485+
* Check if Auctane API is installed
486+
*
487+
* @return bool
488+
*/
489+
public function isAuctaneApiInstalled(): bool
490+
{
491+
try {
492+
// In the "Single Store" case, getting the config of a non-existent path can throw.
493+
// This corresponds to "missing Shipstation Extension"
494+
$value = $this->getConfig(self::XML_PATH_AUCTANE_API_ACTIVE);
495+
} catch (\Exception $e) {
496+
return false;
497+
}
498+
return $value === '1';
499+
}
500+
483501
/**
484502
* Is auto newsletter subscription on
485503
*

0 commit comments

Comments
 (0)