Skip to content

Commit

Permalink
Merge pull request #34 from Datatrics/release/1.6.4
Browse files Browse the repository at this point in the history
Release/1.6.4
  • Loading branch information
Marvin-Magmodules authored Oct 29, 2022
2 parents 070f52c + 7c00248 commit 90f5bee
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 24 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ jobs:
MAGENTO_VERSION: 2.3.7
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.2
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions Api/Config/System/ContentInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface ContentInterface extends RepositoryInterface
public const XML_PATH_GROUPED_USE_NON_VISIBLE_FALLBACK = 'datatrics_connect_product/types/grouped_nonvisible';

/* Filters */
public const XML_PATH_FILTER_BY_STATUS = 'datatrics_connect_product/product_filter/add_disabled';
public const XML_PATH_FILTER_BY_VISIBILITY = 'datatrics_connect_product/product_filter/visbility_enabled';
public const XML_PATH_VISIBILITY = 'datatrics_connect_product/product_filter/visbility';
public const XML_PATH_RESTRICT_BY_CATEGORY = 'datatrics_connect_product/product_filter/category_enabled';
Expand Down
13 changes: 8 additions & 5 deletions Controller/Adminhtml/Content/Update.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ public function execute()
$connection = $this->contentResource->getConnection();
$selectProductIds = $connection->select()->from(
$this->contentResource->getTable('datatrics_content_store'),
['product_id']
)->where('status = ?', 'Queued for Update')
->where('store_id = ?', $storeId)
'product_id'
)->where('status = :status')
->where('store_id = :store_id')
->limit($this->contentConfigRepository->getProcessingLimit($storeId));

$productIds = $connection->fetchCol($selectProductIds, 'product_id');
$bind = [
':status' => 'Queued for Update',
':store_id' => $storeId
];
$productIds = $connection->fetchCol($selectProductIds, $bind);
$count = $productIds ? $this->contentUpdate->prepareData($productIds, $storeId) : 0;

if ($count > 0) {
Expand Down
2 changes: 1 addition & 1 deletion Model/Command/CategoryUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function run(InputInterface $input, OutputInterface $output)
['eav_attribute' => $this->categoryResource->getTable('catalog_category_entity')],
'entity_id'
);
$entityIds = $connection->fetchCol($select, 'entity_id');
$entityIds = $connection->fetchCol($select);
$this->collector->addData('entity_ids', $entityIds, 'all');
$this->collector->addData('entity_type_code', 'catalog_category', 'attributeMapper');
$this->collector->addData('type', 'category', 'url');
Expand Down
2 changes: 1 addition & 1 deletion Model/Command/ContentUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public function run(InputInterface $input, OutputInterface $output)
if (!$connection->fetchOne($select)) {
return 0;
}
$productIds = $connection->fetchCol($select, 'product_id');
$productIds = $connection->fetchCol($select);
$count = $productIds ? $this->prepareData($productIds, $storeId) : 0;
$this->initProgressBar($output, $count);
return 0;
Expand Down
6 changes: 6 additions & 0 deletions Model/Config/System/ContentRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,7 @@ public function groupedNonVisibleFallback(int $storeId): bool
public function getFilters(int $storeId): array
{
return [
'add_disabled_products' => $this->addDisableProducts($storeId),
'filter_by_visibility' => $this->restricProductFeedByVisibility($storeId),
'visibility' => $this->productFeedVisibilityRestrictions($storeId),
'restrict_by_category' => $this->restrictProductFeedByCategory($storeId),
Expand All @@ -377,6 +378,11 @@ public function getFilters(int $storeId): array
];
}

private function addDisableProducts(int $storeId): bool
{
return $this->isSetFlag(self::XML_PATH_FILTER_BY_STATUS, $storeId);
}

/**
* Restrict by 'visibility'
*
Expand Down
2 changes: 1 addition & 1 deletion Model/Content/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public function prepareContentData(array $productIds)
$contents = $connection->fetchAll($selectContent);
$toInvalidate = [];
$skip = 0;
$toAdd = array_diff($productIds, $connection->fetchCol($selectContent, 'product_id'));
$toAdd = array_diff($productIds, $connection->fetchCol($selectContent));
foreach ($contents as $content) {
if ($content['status'] != 0) {
$toInvalidate[] = $content['product_id'];
Expand Down
8 changes: 4 additions & 4 deletions Model/Cron/ContentMaintenance.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ private function collectProductsToDelete()
'entity_id'
]
);
$magentoProductIds = $connection->fetchCol($selectMagentoProducts, 'entity_id');
$magentoProductIds = $connection->fetchCol($selectMagentoProducts);
$selectDatatricsProducts = $connection->select()->from(
$this->contentResource->getTable('datatrics_content'),
[
'content_id'
]
);
$datatricsProductIds = $connection->fetchCol($selectDatatricsProducts, 'content_id');
$datatricsProductIds = $connection->fetchCol($selectDatatricsProducts);
$toDelete = array_diff($datatricsProductIds, $magentoProductIds);
$connection->update(
$this->contentResource->getTable('datatrics_content_store'),
Expand Down Expand Up @@ -139,14 +139,14 @@ private function collectProductsToAdd()
'entity_id'
]
);
$magentoProductIds = $connection->fetchCol($selectMagentoProducts, 'entity_id');
$magentoProductIds = $connection->fetchCol($selectMagentoProducts);
$selectDatatricsProducts = $connection->select()->from(
$this->contentResource->getTable('datatrics_content_store'),
[
'product_id'
]
);
$datatricsProductIds = $connection->fetchCol($selectDatatricsProducts, 'product_id');
$datatricsProductIds = $connection->fetchCol($selectDatatricsProducts);
$toAdd = array_diff($magentoProductIds, $datatricsProductIds);
return $toAdd;
}
Expand Down
4 changes: 2 additions & 2 deletions Model/Cron/ContentUpdate.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ private function deleteProducts()
'product_id'
]
)->where('status = ?', 'Queued for Delete');
$productIds = $connection->fetchCol($select, 'product_id');
$productIds = $connection->fetchCol($select);
$where = [
'product_id in (?)' => $productIds
];
Expand Down Expand Up @@ -155,7 +155,7 @@ private function processStoreData(int $storeId)
if (!$connection->fetchOne($select)) {
return;
}
$productIds = $connection->fetchCol($select, 'product_id');
$productIds = $connection->fetchCol($select);
$this->commandContentUpdate->prepareData($productIds, $storeId);
}
}
12 changes: 6 additions & 6 deletions Service/ProductData/Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function execute(array $filter, int $storeId = 0): array
if ($storeId) {
$entityIds = $this->filterWebsite($entityIds, $storeId);
}
if (!empty($filter['add_disabled_products'])) {
if (!$filter['add_disabled_products']) {
$entityIds = $this->filterEnabledStatus($entityIds);
}

Expand Down Expand Up @@ -98,7 +98,7 @@ private function filterVisibility(array $visibility): array
)->where('value IN (?)', $visibility)
->where('attribute_code = ?', 'visibility')
->where('store_id IN (?)', [0]);
return $connection->fetchCol($select, 'catalog_product_entity_int.' . $this->entityId);
return $connection->fetchCol($select);
}

/**
Expand All @@ -120,7 +120,7 @@ private function filterWebsite(array $entityIds, int $storeId): array
['product_id']
)->where('store.store_id = ?', $storeId)
->where('catalog_product_website.product_id in (?)', $entityIds);
return $connection->fetchCol($select, 'catalog_product_website.product_id');
return $connection->fetchCol($select);
}

/**
Expand All @@ -134,7 +134,7 @@ private function filterEnabledStatus(array $entityIds): array
$connection = $this->resourceConnection->getConnection();
$select = $connection->select()->distinct()->from(
['catalog_product_entity_int' => $this->resourceConnection->getTableName('catalog_product_entity_int')],
[$this->entityId, 'value']
[$this->entityId]
)->joinLeft(
['eav_attribute' => $this->resourceConnection->getTableName('eav_attribute')],
'eav_attribute.attribute_id = catalog_product_entity_int.attribute_id',
Expand All @@ -143,7 +143,7 @@ private function filterEnabledStatus(array $entityIds): array
->where('attribute_code = ?', 'status')
->where('store_id IN (?)', [0])
->where($this->entityId . ' IN (?)', $entityIds);
return $connection->fetchCol($select, 'catalog_product_entity_int.' . $this->entityId);
return $connection->fetchCol($select);
}

/**
Expand All @@ -169,6 +169,6 @@ private function filterByCategories(
} else {
$select->where('category_id not in (?)', $categoryIds);
}
return $connection->fetchCol($select, 'product_id');
return $connection->fetchCol($select);
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "datatrics/magento2-integration",
"description": "Datatrics Connect extension for Magento 2",
"type": "magento2-module",
"version": "1.6.3",
"version": "1.6.4",
"license": [
"BSD-2-Clause"
],
Expand Down
2 changes: 1 addition & 1 deletion etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<default>
<datatrics_connect_general>
<general>
<version>v1.6.3</version>
<version>v1.6.4</version>
<enable>0</enable>
<source>Magento 2</source>
<debug>0</debug>
Expand Down

0 comments on commit 90f5bee

Please sign in to comment.