| @@ -21,7 +21,7 @@ class EnabledGroupFactory extends AbstractFactory { | |||
| return new EnabledGroup(); | |||
| } | |||
| public function updateSheetSettingsEnabledGroups(int $sheetSettingId, array $newGroups, string $componentBased = null): void { | |||
| public function updateSheetSettingsEnabledGroups(int $sheetSettingId, array $newGroups, bool $componentBased): void { | |||
| $activeGroups = $this->findAllEnabledGroups($sheetSettingId, $componentBased); | |||
| foreach ($activeGroups as $activeGroup) { | |||
| if ($activeGroup->isComponentBased() && $componentBased) { | |||
| @@ -45,13 +45,15 @@ class EnabledGroupFactory extends AbstractFactory { | |||
| } | |||
| } | |||
| public function findAllEnabledGroups(int $sheetSettingId = null, string $componentBased = null): array { | |||
| public function findAllEnabledGroups(int $sheetSettingId = null, bool $componentBased): array { | |||
| $list = []; | |||
| if ($componentBased) { | |||
| if ($sheetSettingId) { | |||
| if ($sheetSettingId !== null) { | |||
| \Drupal::messenger()->addStatus('not null'.$sheetSettingId.' '.$componentBased); | |||
| $list = $this->getConnection() | |||
| ->select($this->getActiveTable(), 'w') | |||
| ->fields('w') | |||
| ->condition('w.status', Status::ACTIVE) | |||
| ->condition('sheet_setting_id', $sheetSettingId) | |||
| ->isNull('w.deleted_at') | |||
| ->isNull('w.category_id') | |||
| @@ -59,6 +61,7 @@ class EnabledGroupFactory extends AbstractFactory { | |||
| ->execute() | |||
| ->fetchAll(); | |||
| } else { | |||
| \Drupal::messenger()->addStatus('not null'.$sheetSettingId.' '.$componentBased); | |||
| $list = $this->getConnection() | |||
| ->select($this->getActiveTable(), 'w') | |||
| ->fields('w') | |||
| @@ -355,9 +355,6 @@ class ProductFactory extends AbstractFactory { | |||
| if ($product->getFabricName()) { | |||
| $needles[] = $product->getFabricName(); | |||
| } | |||
| if (empty($needles)) { | |||
| return $existingProduct; | |||
| } | |||
| foreach ($fields as $field) { | |||
| if (!empty($existingProduct)) { | |||
| continue; | |||
| @@ -1050,7 +1047,7 @@ class ProductFactory extends AbstractFactory { | |||
| return $entities; | |||
| } | |||
| protected function insert(AbstractEntity $entity): Product { | |||
| protected function insert($entity): Product { | |||
| $id = $this->getConnection() | |||
| ->insert($this->getActiveTable()) | |||
| ->fields([ | |||
| @@ -1111,7 +1108,7 @@ class ProductFactory extends AbstractFactory { | |||
| return $entity; | |||
| } | |||
| protected function update(AbstractEntity $entity): Product { | |||
| protected function update($entity): Product { | |||
| $this->getConnection() | |||
| ->update($this->getActiveTable()) | |||
| ->fields([ | |||
| @@ -241,7 +241,7 @@ class CalculationEdit extends ArlistaAbstractForm { | |||
| public function getEnabledCategoriesRenderedForm(array $form): array { | |||
| $this->categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | |||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups(null, null); | |||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups(null, false); | |||
| $selected = []; | |||
| /* @var $enabledGroup EnabledGroup */ | |||
| foreach ($enabledGroups as $enabledGroup) { | |||
| @@ -47,7 +47,7 @@ class EnabledGroupListForm extends ArlistaAbstractForm { | |||
| public function getEnableCategoriesForm(array $form, int $mid, int $sheetSettingId): array { | |||
| $categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | |||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSettingId, null); | |||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSettingId, false); | |||
| $selected = []; | |||
| /* @var $enabledGroup EnabledGroup */ | |||
| foreach ($enabledGroups as $enabledGroup) { | |||
| @@ -190,7 +190,7 @@ class EnabledGroupListForm extends ArlistaAbstractForm { | |||
| unset($enabled[$key]); | |||
| } | |||
| } | |||
| $this->getEnabledGroupFactory()->updateSheetSettingsEnabledGroups($this->sheetSettingId, $enabled); | |||
| $this->getEnabledGroupFactory()->updateSheetSettingsEnabledGroups($this->sheetSettingId, $enabled, false); | |||
| $this->getCacheService()->resetCache([ | |||
| 'arlista_product_uploaded_list_form', $this->mid, $this->sheetSettingId, 'enabled_categories']); | |||
| \Drupal::messenger()->addStatus('Sikeres mentés!'); | |||
| @@ -229,6 +229,12 @@ class ProductUploadedList extends ArlistaAbstractForm { | |||
| $enabledComponents[$component->getId()] = $component; | |||
| } | |||
| } | |||
| /* @var $enabledGroup EnabledGroup */ | |||
| /*foreach($enabledGroups as $enabledGroup) { | |||
| if (isset($enabledGroups[$component->getId()])) { | |||
| $enabledComponents[$component->getId()] = $component; | |||
| } | |||
| }*/ | |||
| $this->manufacturersList = $this->getComponentManufacturersList($enabledComponents); | |||
| $this->enabledComponents = $enabledComponents; | |||
| //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | |||