Skip to content

Commit

Permalink
Cleanup deadcode
Browse files Browse the repository at this point in the history
  • Loading branch information
supercid committed Feb 17, 2025
1 parent 57fb34e commit a658a56
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 74 deletions.
69 changes: 0 additions & 69 deletions Model/Category/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,6 @@
namespace Nosto\Tagging\Model\Category;

use Magento\Catalog\Api\Data\CategoryInterface;
use Magento\Catalog\Model\CategoryRepository;
use Magento\Catalog\Model\ResourceModel\Category\Collection as CategoryCollection;
use Magento\Framework\Api\SearchCriteriaBuilder;
use Magento\Framework\Exception\LocalizedException;
use Magento\Store\Model\Store;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory as CategoryCollectionFactory;
use Nosto\Tagging\Exception\ParentCategoryDisabledException;

/**
Expand All @@ -52,43 +46,6 @@ class Repository
{
private array $parentCategoryIdCache = [];

/** @var SearchCriteriaBuilder $searchCriteriaBuilder */
private SearchCriteriaBuilder $searchCriteriaBuilder;

/** @var CategoryRepository $categoryRepository */
private CategoryRepository $categoryRepository;

/** @var CategoryCollectionFactory $categoryCollectionFactory */
private CategoryCollectionFactory $categoryCollectionFactory;

/**
* @param SearchCriteriaBuilder $searchCriteriaBuilder
*/
public function __construct(
SearchCriteriaBuilder $searchCriteriaBuilder,
CategoryRepository $categoryRepository,
CategoryCollectionFactory $categoryCollectionFactory
) {
$this->searchCriteriaBuilder = $searchCriteriaBuilder;
$this->categoryRepository = $categoryRepository;
$this->categoryCollectionFactory = $categoryCollectionFactory;
}

/**
* Gets categories by category ids
*
* @param array $ids
* @return mixed
*/
public function getByIds(array $ids)
{
$searchCriteria = $this->searchCriteriaBuilder
->addFilter('entity_id', $ids, 'in')
->create();
/** @noinspection PhpUndefinedMethodInspection */
return $this->categoryRepository->getList($searchCriteria);
}

/**
* Gets the parent category ID's for a given category
*
Expand Down Expand Up @@ -121,31 +78,6 @@ public function resolveParentCategoryIds(CategoryInterface $category): ?array
return $parentCategoryIds;
}

/**
* @param Store $store
* @param array $categoryIds
*
* @return CategoryCollection
* @throws LocalizedException
*/
public function getCategoryCollectionQuery(Store $store, array $categoryIds = [])
{
$categories = $this->categoryCollectionFactory->create()
->distinct(true)
->addNameToResult()
->setStoreId($store->getId())
->addUrlRewriteToResult()
->addAttributeToFilter('level', ['gt' => 1])
->addAttributeToSelect(array_merge(['name', 'is_active', 'include_in_menu']))
->addOrderField('entity_id');

if ($categoryIds) {
$categories->addAttributeToFilter('entity_id', ['in' => $categoryIds]);
}

return $categories;
}

/**
* Get Parent Category IDS
*
Expand Down Expand Up @@ -181,5 +113,4 @@ private function saveParentIdsToCache(CategoryInterface $category, array $parent
{
$this->parentCategoryIdCache[$category->getId()] = $parentCategoryIds;
}

}
1 change: 1 addition & 0 deletions Model/Service/Sync/AbstractBulkPublisher.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private function publishCollectionToMessageQueue(
}

$bulkUuid = $this->identityService->generateId();
/** @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal */
$bulkDescription = __('Sync ' . count($entityIds) . ' Nosto entities');
$operations = $this->generateOperationsChunks($entityIds, $storeId, $bulkUuid);

Expand Down
18 changes: 14 additions & 4 deletions Model/Service/Sync/Upsert/Category/SyncService.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,20 @@ public function sync(CategoryCollection $collection, Store $store)
$this->checkMemoryConsumption('category sync');
foreach ($page as $category) {
// @TODO: Adjust on the SDK to batch instead of calling the API for each category

Check warning on line 116 in Model/Service/Sync/Upsert/Category/SyncService.php

View workflow job for this annotation

GitHub Actions / Code Sniffer

Comment refers to a TODO task "Adjust on the SDK to batch instead of calling the API for each category"
$nostoCategory = $this->categoryBuilder->build($category, $store);
$op = new CategoryUpdate($nostoCategory, $account, $this->nostoHelperUrl->getActiveDomain($store));
$op->setResponseTimeout($this->apiTimeout);
$op->execute();
try {
$nostoCategory = $this->categoryBuilder->build($category, $store);
$op = new CategoryUpdate($nostoCategory, $account, $this->nostoHelperUrl->getActiveDomain($store));
$op->setResponseTimeout($this->apiTimeout);
$op->execute();
} catch (Exception $e) {
$this->getLogger()->error(
sprintf(
'Failed to sync category with id %s - %s',
$category->getId(),
$e->getMessage()
)
);
}
}
$this->logDebugWithStore(
sprintf(
Expand Down
1 change: 0 additions & 1 deletion Observer/Order/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
use Magento\Framework\Module\Manager as ModuleManager;
use Magento\Sales\Model\Order;
use Magento\Store\Model\Store;
use Nosto\Model\Order\Buyer;
use Nosto\Model\Order\Order as NostoOrder;
use Nosto\Operation\Order\OrderCreate as NostoOrderCreate;
use Nosto\Operation\Order\OrderStatus as NostoOrderUpdate;
Expand Down

0 comments on commit a658a56

Please sign in to comment.