Skip to content

Commit

Permalink
Merge pull request #21 from magmodules/release/1.5.7
Browse files Browse the repository at this point in the history
Release/1.5.7
  • Loading branch information
Marvin-Magmodules authored Mar 22, 2023
2 parents e0c9ae5 + 87da8a7 commit 152ca4d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 33 deletions.
8 changes: 5 additions & 3 deletions .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: phpstan
on: [pull_request]
on: [ pull_request ]

jobs:
build:
Expand All @@ -8,6 +8,8 @@ jobs:
include:
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6

runs-on: ubuntu-latest
steps:
Expand All @@ -23,10 +25,10 @@ jobs:
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extensions in Magento
run: docker exec magento-project-community-edition composer require magmodules/magento2-reloadify:dev-continuous-integration-test-branch
run: docker exec magento-project-community-edition composer require magmodules/magento2-reloadify:@dev --no-plugins

- name: Activate the extension
run: docker exec magento-project-community-edition bash -c "php bin/magento module:enable Magmodules_Reloadify && php bin/magento setup:upgrade && php bin/magento setup:di:compile"
run: docker exec magento-project-community-edition ./retry "php bin/magento module:enable Magmodules_Reloadify && php bin/magento setup:upgrade && php bin/magento setup:di:compile"

- name: Run PHPStan
run: docker exec magento-project-community-edition /bin/bash -c "./vendor/bin/phpstan analyse --no-progress -c /data/extensions/*/phpstan.neon /data/extensions"
25 changes: 11 additions & 14 deletions .github/workflows/setup-di-compile.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
name: setup:di:compile

on: pull_request

jobs:
build:
strategy:
matrix:
include:
- PHP_VERSION: php71-fpm
MAGENTO_VERSION: 2.3.3
- PHP_VERSION: php73-fpm
MAGENTO_VERSION: 2.3.7
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.0
- PHP_VERSION: php74-fpm
MAGENTO_VERSION: 2.4.3-with-replacements
- PHP_VERSION: php81-fpm
MAGENTO_VERSION: 2.4.4
- PHP_VERSION: php82-fpm
MAGENTO_VERSION: 2.4.6
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v1

- name: Start Docker
run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }}
- name: Start Docker
run: docker run --detach --name magento-project-community-edition michielgerritsen/magento-project-community-edition:${{ matrix.PHP_VERSION }}-magento${{ matrix.MAGENTO_VERSION }}

- name: Upload our code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/
- name: Upload our code into the docker container
run: docker cp $(pwd) magento-project-community-edition:/data/extensions/

- name: Install the extension in Magento
run: docker exec magento-project-community-edition composer require magmodules/magento2-reloadify:@dev
- name: Install the extension in Magento
run: docker exec magento-project-community-edition composer require magmodules/magento2-reloadify:@dev --no-plugins

- name: Run setup:di:compile
run: docker exec magento-project-community-edition php bin/magento setup:di:compile
- name: Run setup:di:compile
run: docker exec magento-project-community-edition ./retry "php bin/magento setup:di:compile"
8 changes: 4 additions & 4 deletions Service/ProductData/Stock.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,23 @@ private function collectMsi(array $channels): array
if (!$this->resource->getConnection()->tableColumnExists($stockTable, 'website_id')) {
$selectStock->joinLeft(
$stockTable,
"${stockTable}.sku = ${stockTablePrimary}.sku",
"{$stockTable}.sku = {$stockTablePrimary}.sku",
[
sprintf('quantity_%s', $channel) => 'quantity'
]
);
} else {
$selectStock->joinLeft(
$stockTable,
"${stockTable}.website_id = ${stockTablePrimary}.website_id and
${stockTable}.product_id = ${stockTablePrimary}.product_id",
"{$stockTable}.website_id = {$stockTablePrimary}.website_id and
{$stockTable}.product_id = {$stockTablePrimary}.product_id",
[
sprintf('quantity_%s', $channel) => 'quantity'
]
);
}
}
$selectStock->where("${stockTablePrimary}.product_id IN (?)", $this->entityIds);
$selectStock->where("{$stockTablePrimary}.product_id IN (?)", $this->entityIds);
return $this->resource->getConnection()->fetchAll($selectStock);
}

Expand Down
41 changes: 31 additions & 10 deletions Service/WebApi/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@

namespace Magmodules\Reloadify\Service\WebApi;

use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Catalog\Model\Category as CategoryModel;
use Magento\Catalog\Model\ResourceModel\Category\Collection;
use Magento\Catalog\Model\ResourceModel\Category\CollectionFactory;
use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory;
use Magento\Framework\Api\SearchCriteria\CollectionProcessorInterface;
use Magento\Framework\Api\SearchCriteriaInterface;
use Magento\Framework\Exception\LocalizedException;
Expand All @@ -23,7 +25,7 @@ class Category
* Default attribute map output
*/
public const DEFAULT_MAP = [
"id" =>'entity_id',
"id" => 'entity_id',
"name" => 'name',
"created_at" => 'created_at',
"updated_at" => 'updated_at'
Expand All @@ -37,22 +39,29 @@ class Category
* @var CollectionProcessorInterface
*/
private $collectionProcessor;
/**
* @var ProductCollectionFactory
*/
private $productCollectionFactory;

/**
* Category constructor.
* @param CollectionFactory $collectionFactory
* @param ProductCollectionFactory $productCollectionFactory
* @param CollectionProcessorInterface $collectionProcessor
*/
public function __construct(
CollectionFactory $collectionFactory,
ProductCollectionFactory $productCollectionFactory,
CollectionProcessorInterface $collectionProcessor
) {
$this->collectionFactory = $collectionFactory;
$this->productCollectionFactory = $productCollectionFactory;
$this->collectionProcessor = $collectionProcessor;
}

/**
* @param int $storeId
* @param array $extra
* @param int $storeId
* @param array $extra
* @param SearchCriteriaInterface|null $searchCriteria
*
* @return array
Expand All @@ -62,14 +71,13 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
{
$data = [];
$collection = $this->getCollection($storeId, $extra, $searchCriteria);

foreach ($collection as $category) {
$data[] = [
"id" => $category->getId(),
"name" => $category->getName(),
"url" => $category->getUrl(),
"visible" => $category->getIsActive(),
"product_ids" => $category->getProductCollection()->getColumnValues('entity_id'),
"product_ids" => $this->getProductIds($storeId, $category),
"parent_category_id" => $this->getParentCategoryId($category),
"created_at" => $category->getCreatedAt(),
"updated_at" => $category->getUpdatedAt()
Expand All @@ -79,8 +87,8 @@ public function execute(int $storeId, array $extra = [], SearchCriteriaInterface
}

/**
* @param int $storeId
* @param array $extra
* @param int $storeId
* @param array $extra
* @param SearchCriteriaInterface|null $searchCriteria
*
* @return Collection
Expand Down Expand Up @@ -113,14 +121,27 @@ private function getCollection(
*
* @return Collection
*/
private function applyFilter(Collection $categories, array $filters)
private function applyFilter(Collection $categories, array $filters): Collection
{
foreach ($filters as $field => $filter) {
$categories->addFieldToFilter(self::DEFAULT_MAP[$field], $filter);
}
return $categories;
}

/**
* @param int $storeId
* @param CategoryModel $category
* @return array|null
*/
private function getProductIds(int $storeId, CategoryModel $category): ?array
{
return $this->productCollectionFactory->create()
->setStoreId($storeId)
->addCategoryFilter($category)
->getColumnValues('entity_id');
}

/**
* @param $category
*
Expand Down
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": "magmodules/magento2-reloadify",
"description": "Reloadify extension for Magento 2",
"type": "magento2-module",
"version": "1.5.6",
"version": "1.5.7",
"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>
<magmodules_reloadify>
<general>
<version>v1.5.6</version>
<version>v1.5.7</version>
<enable>0</enable>
<debug>0</debug>
</general>
Expand Down

0 comments on commit 152ca4d

Please sign in to comment.