Skip to content

Commit

Permalink
Add support for non default product types
Browse files Browse the repository at this point in the history
  • Loading branch information
Marvin-Magmodules committed Jan 30, 2025
1 parent 8f78d2e commit 4ce383c
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions Helper/Source.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Magmodules\Channable\Helper;

use Magento\Catalog\Model\Product\TypeFactory;
use Magento\Framework\App\Helper\AbstractHelper;
use Magento\Framework\App\Helper\Context;
use Magento\Framework\Exception\NoSuchEntityException;
Expand Down Expand Up @@ -94,6 +95,10 @@ class Source extends AbstractHelper
* @var InventorySource
*/
private $inventorySource;
/**
* @var TypeFactory
*/
private $typeFactory;
/**
* @var
*/
Expand All @@ -105,11 +110,13 @@ public function __construct(
General $generalHelper,
Product $productHelper,
InventorySource $inventorySource,
TypeFactory $typeFactory,
Item $itemHelper
) {
$this->generalHelper = $generalHelper;
$this->productHelper = $productHelper;
$this->itemHelper = $itemHelper;
$this->typeFactory = $typeFactory;
$this->storeManager = $storeManager;
$this->inventorySource = $inventorySource;
parent::__construct($context);
Expand Down Expand Up @@ -174,21 +181,28 @@ public function getStoreId($storeId = null)
return $this->storeId;
}

private function getAllProductTypeIds(): array
{
$typeInstance = $this->typeFactory->create();
return array_keys($typeInstance->getOptionArray());
}

/**
* @param $type
*
* @return array
*/
public function getProductFilters($type)
public function getProductFilters($type): array
{
$filters = [];
$filters['type_id'] = ['simple', 'downloadable', 'virtual', 'giftcard'];
$filters['relations'] = [];
$filters['exclude_parents'] = [];
$filters['nonvisible'] = [];
$filters['parent_attributes'] = [];
$filters['image'] = [];
$filters['link'] = [];
$filters = [
'type_id' => array_diff($this->getAllProductTypeIds(), ['configurable', 'bundle', 'grouped']),
'relations' => [],
'exclude_parents' => [],
'nonvisible' => [],
'parent_attributes' => [],
'image' => [],
'link' => [],
];

$configurabale = $this->getStoreValue(self::XPATH_CONFIGURABLE);
switch ($configurabale) {
Expand Down

0 comments on commit 4ce383c

Please sign in to comment.