Skip to content

Commit

Permalink
Fix config
Browse files Browse the repository at this point in the history
  • Loading branch information
ah-net committed Nov 20, 2024
1 parent 944cfc0 commit b15fbe6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Model/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,7 @@ public function getSearchLanguage(Store $store = null)
* @return mixed|string|null
* @throws LocalizedException
*/
public function getStoreConfig(string $path, Store $store = null)
protected function getStoreConfig(string $path, Store $store = null)
{
if ($store) {
return $store->getConfig($path);
Expand Down
15 changes: 15 additions & 0 deletions Model/PersonalMerchandisingConfig.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Tweakwise\Magento2Tweakwise\Model;

class PersonalMerchandisingConfig extends Config
{
/**
* @param Store|null $store
* @return bool
*/
public function isAnalyticsEnabled(Store $store = null)
{
return (bool)$this->getStoreConfig('tweakwise/personal_merchandising/analytics_enabled', $store);
}
}
16 changes: 13 additions & 3 deletions Observer/TweakwiseCheckout.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,35 @@
use Tweakwise\Magento2Tweakwise\Model\Client;
use Tweakwise\Magento2Tweakwise\Model\Client\RequestFactory;
use Magento\Framework\App\Request\Http as Request;
use Tweakwise\Magento2Tweakwise\Model\PersonalMerchandisingConfig;
use Tweakwise\Magento2TweakwiseExport\Model\Helper;
use Magento\Store\Model\StoreManagerInterface;
use Tweakwise\Magento2Tweakwise\Model\Config;

class TweakwiseCheckout implements ObserverInterface
{
/**
* Constructor.
*
* @param RequestFactory $requestFactory
* @param Client $client
* @param Helper $helper
* @param StoreManagerInterface $storeManager
* @param PersonalMerchandisingConfig $config
* @param CookieManagerInterface $cookieManager
*/
public function __construct(
private readonly RequestFactory $requestFactory,
private readonly Client $client,
private readonly Helper $helper,
private readonly StoreManagerInterface $storeManager,
private readonly Config $config,
private readonly PersonalMerchandisingConfig $config,
private readonly CookieManagerInterface $cookieManager
) {
}

public function execute(Observer $observer)
{
if ($this->config->getStoreConfig('tweakwise/personal_merchandising/analytics_enabled')) {
if ($this->config->isAnalyticsEnabled('tweakwise/personal_merchandising/analytics_enabled')) {
if ($this->config->isPersonalMerchandisingActive()) {
$order = $observer->getEvent()->getOrder();
// Get the order items
Expand Down

0 comments on commit b15fbe6

Please sign in to comment.