Skip to content

Commit

Permalink
Merge pull request #75 from magmodules/release/2.1.3
Browse files Browse the repository at this point in the history
Release/2.1.3
  • Loading branch information
Marvin-Magmodules authored Jun 19, 2024
2 parents e49f279 + 24e0bf9 commit 4659765
Show file tree
Hide file tree
Showing 16 changed files with 39 additions and 248 deletions.
16 changes: 0 additions & 16 deletions Api/Config/System/DataInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,27 +167,11 @@ public function getCmsEnableType(int $storeId): int;
*/
public function getCmsSelection(int $storeId): string;

/**
* Get Category has changed flag
*
* @return bool
*/
public function getCategoryChangedFlag(): bool;

/**
* Add rating summary
*
* @param int $storeId
* @return bool
*/
public function addRatingSummary(int $storeId): bool;

/**
* Set/unset a flag when category data is changed
*
* @param bool $value
*
* @return void
*/
public function setCategoryChangedFlag(bool $value): void;
}
2 changes: 0 additions & 2 deletions Controller/Adminhtml/Feed/Generate.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,6 @@ public function execute(): Redirect
}
}

$this->configProvider->setCategoryChangedFlag(false);

/** @var Redirect $resultRedirect */
$resultRedirect = $this->resultFactory->create(ResultFactory::TYPE_REDIRECT);
$resultRedirect->setUrl($this->redirect->getRefererUrl());
Expand Down
2 changes: 0 additions & 2 deletions Cron/Delta.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ public function execute()
$this->logRepository->addErrorLog('Generate', $e->getMessage());
}
}

$this->configProvider->setCategoryChangedFlag(false);
}
}
2 changes: 0 additions & 2 deletions Cron/Feed.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,5 @@ public function execute()
$this->logRepository->addErrorLog('Generate', $e->getMessage());
}
}

$this->configProvider->setCategoryChangedFlag(false);
}
}
10 changes: 9 additions & 1 deletion Model/Config/Source/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,15 @@ function ($a, $b) {
*/
public function getNonAvailableAttributes(): array
{
return ['categories', 'gallery', 'category_ids', 'quantity_and_stock_status', 'price', 'special_price'];
return [
'categories',
'gallery',
'category_ids',
'quantity_and_stock_status',
'price',
'special_price',
'media_gallery'
];
}

/**
Expand Down
23 changes: 0 additions & 23 deletions Model/Config/System/DataRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -476,29 +476,6 @@ public function getCmsSelection(int $storeId): string
return $this->getStoreValue(self::XML_PATH_CMS_SELECTION, $storeId);
}

/**
* @inheritDoc
*/
public function setCategoryChangedFlag(bool $value): void
{
$this->setConfigData((int)$value, self::CATEGORY_CHANGED_FLAG_PATH);
}

/**
* @inheritDoc
*/
public function getCategoryChangedFlag(): bool
{
// we can't use scopeConfigInterface because of cache issue
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()->from(
[$this->resourceConnection->getTableName('core_config_data')],
['value']
)->where('path = :path');
$bind = [':path' => self::CATEGORY_CHANGED_FLAG_PATH];
return (bool)$connection->fetchOne($select, $bind);
}

/**
* @inheritDoc
*/
Expand Down
13 changes: 0 additions & 13 deletions Model/Generate/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Magmodules\Sooqr\Model\Config\Source\FeedExecBy;
use Magmodules\Sooqr\Model\Config\Source\FeedType;
use Magmodules\Sooqr\Service\Api\Adapter;
use Magmodules\Sooqr\Service\CategoryData\Tree as CategoryDataTree;
use Magmodules\Sooqr\Service\Delta\Get as GetDelta;
use Magmodules\Sooqr\Service\Feed\Create as FeedService;
use Magento\Framework\Filesystem\Driver\File;
Expand Down Expand Up @@ -60,10 +59,6 @@ class Repository implements GenerateRepository
* @var DirectoryList
*/
private $directoryList;
/**
* @var CategoryDataTree
*/
private $categoryDataTree;
/**
* @var CmsRepository
*/
Expand Down Expand Up @@ -104,7 +99,6 @@ class Repository implements GenerateRepository
* @param DateTime $datetime
* @param FeedService $feedService
* @param ProductDataRepository $productDataRepository
* @param CategoryDataTree $categoryDataTree
* @param DirectoryList $directoryList
* @param CmsRepository $cmsRepository
* @param FeedRepository $feedRepository
Expand All @@ -120,7 +114,6 @@ public function __construct(
DateTime $datetime,
FeedService $feedService,
ProductDataRepository $productDataRepository,
CategoryDataTree $categoryDataTree,
DirectoryList $directoryList,
CmsRepository $cmsRepository,
FeedRepository $feedRepository,
Expand All @@ -135,7 +128,6 @@ public function __construct(
$this->datetime = $datetime;
$this->feedService = $feedService;
$this->productDataRepository = $productDataRepository;
$this->categoryDataTree = $categoryDataTree;
$this->directoryList = $directoryList;
$this->cmsRepository = $cmsRepository;
$this->feedRepository = $feedRepository;
Expand Down Expand Up @@ -230,10 +222,6 @@ public function execute(int $storeId, int $type = FeedType::FULL, int $executedB
];
$generatedEntities[] = 'products';
}
if ($this->configProvider->getCategoryChangedFlag()) {
$dataFeed['category_tree'] = $this->categoryDataTree->execute($storeId);
$generatedEntities[] = 'categories';
}
break;
case FeedType::PREVIEW:
$products = $this->productDataRepository->getProductData($storeId, null, $type);
Expand All @@ -249,7 +237,6 @@ public function execute(int $storeId, int $type = FeedType::FULL, int $executedB
$dataFeed = [
'config' => $this->configProvider->getFeedHeader($storeId),
'products' => array_merge($products, $this->cmsRepository->getCmsPages($storeId)),
'category_tree' => $this->categoryDataTree->execute($storeId),
'results' => $this->configProvider->getFeedFooter(count($products))
];
$generatedEntities = ['products', 'categories', 'cms_pages'];
Expand Down
17 changes: 8 additions & 9 deletions Model/ProductData/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ private function addImageData(int $storeId, int $entityId, array &$productData):
break;
}
}

$productData['image'] = $this->getImageWithFallback($imageData, [$storeId, 0]);
}

Expand Down Expand Up @@ -357,7 +357,7 @@ private function addStaticFields(array &$productData): void
}

/**
* Attribute data preperation
* Attribute data preparation
*
* @param string $attribute
* @param array $productData
Expand Down Expand Up @@ -468,14 +468,13 @@ private function categoryData(array $productData): array
if (empty($productData['category'])) {
return $categoryData;
}
$i = 1;

foreach ($productData['category'] as $category) {
$path = explode(' > ', $category['path']);
$categoryData["sqr:category{$i}"] = [
'node' => end($path),
];
$categoryData["sqr:categories"][] = $category['category_id'];
$i++;
$categoryNames = explode(' > ', $category['path']);
foreach ($categoryNames as $k => $categoryName) {
$key = $k + 1;
$categoryData["sqr:category{$key}"][] = $categoryName;
}
}

return $categoryData;
Expand Down
46 changes: 0 additions & 46 deletions Plugin/Catalog/Category/Save.php

This file was deleted.

106 changes: 0 additions & 106 deletions Service/CategoryData/Tree.php

This file was deleted.

20 changes: 4 additions & 16 deletions Service/Feed/Create.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,6 @@ class Create
* @var File
*/
private $file;
/**
* @var bool
*/
private $categoryTree = false;
/**
* @var bool
*/
Expand Down Expand Up @@ -66,18 +62,13 @@ public function createXml(array $data): string
{
$xmlStr = '';
foreach ($data as $key => $value) {
if ($key === 'category_tree') {
$this->categoryTree = true;
}
if ($key === 'sqr:categories') {
if (strpos((string)$key, "sqr:category") === 0) {
$this->categoryNode = true;
}

if (is_numeric($key) && $this->categoryTree) {
$key = 'category_item';
} elseif (is_numeric($key) && $this->categoryNode) {
if (is_numeric($key) && $this->categoryNode) {
$key = 'node';
} elseif (is_numeric($key) && !$this->categoryNode && !$this->categoryTree) {
} elseif (is_numeric($key)) {
$key = 'item';
}
if (!is_array($value)) {
Expand All @@ -95,10 +86,7 @@ public function createXml(array $data): string
$xmlStr .= <<<XML
</$key>
XML;
if ($key == 'category_tree') {
$this->categoryTree = false;
}
if ($key == 'sqr:categories') {
if (strpos((string)$key, "sqr:category") === 0) {
$this->categoryNode = false;
}
}
Expand Down
Loading

0 comments on commit 4659765

Please sign in to comment.