| return new EnabledGroup(); | 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); | $activeGroups = $this->findAllEnabledGroups($sheetSettingId, $componentBased); | ||||
| foreach ($activeGroups as $activeGroup) { | foreach ($activeGroups as $activeGroup) { | ||||
| if ($activeGroup->isComponentBased() && $componentBased) { | if ($activeGroup->isComponentBased() && $componentBased) { | ||||
| } | } | ||||
| } | } | ||||
| public function findAllEnabledGroups(int $sheetSettingId = null, string $componentBased = null): array { | |||||
| public function findAllEnabledGroups(int $sheetSettingId = null, bool $componentBased): array { | |||||
| $list = []; | $list = []; | ||||
| if ($componentBased) { | if ($componentBased) { | ||||
| if ($sheetSettingId) { | |||||
| if ($sheetSettingId !== null) { | |||||
| \Drupal::messenger()->addStatus('not null'.$sheetSettingId.' '.$componentBased); | |||||
| $list = $this->getConnection() | $list = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | ->select($this->getActiveTable(), 'w') | ||||
| ->fields('w') | ->fields('w') | ||||
| ->condition('w.status', Status::ACTIVE) | |||||
| ->condition('sheet_setting_id', $sheetSettingId) | ->condition('sheet_setting_id', $sheetSettingId) | ||||
| ->isNull('w.deleted_at') | ->isNull('w.deleted_at') | ||||
| ->isNull('w.category_id') | ->isNull('w.category_id') | ||||
| ->execute() | ->execute() | ||||
| ->fetchAll(); | ->fetchAll(); | ||||
| } else { | } else { | ||||
| \Drupal::messenger()->addStatus('not null'.$sheetSettingId.' '.$componentBased); | |||||
| $list = $this->getConnection() | $list = $this->getConnection() | ||||
| ->select($this->getActiveTable(), 'w') | ->select($this->getActiveTable(), 'w') | ||||
| ->fields('w') | ->fields('w') |
| if ($product->getFabricName()) { | if ($product->getFabricName()) { | ||||
| $needles[] = $product->getFabricName(); | $needles[] = $product->getFabricName(); | ||||
| } | } | ||||
| if (empty($needles)) { | |||||
| return $existingProduct; | |||||
| } | |||||
| foreach ($fields as $field) { | foreach ($fields as $field) { | ||||
| if (!empty($existingProduct)) { | if (!empty($existingProduct)) { | ||||
| continue; | continue; | ||||
| return $entities; | return $entities; | ||||
| } | } | ||||
| protected function insert(AbstractEntity $entity): Product { | |||||
| protected function insert($entity): Product { | |||||
| $id = $this->getConnection() | $id = $this->getConnection() | ||||
| ->insert($this->getActiveTable()) | ->insert($this->getActiveTable()) | ||||
| ->fields([ | ->fields([ | ||||
| return $entity; | return $entity; | ||||
| } | } | ||||
| protected function update(AbstractEntity $entity): Product { | |||||
| protected function update($entity): Product { | |||||
| $this->getConnection() | $this->getConnection() | ||||
| ->update($this->getActiveTable()) | ->update($this->getActiveTable()) | ||||
| ->fields([ | ->fields([ |
| public function getEnabledCategoriesRenderedForm(array $form): array { | public function getEnabledCategoriesRenderedForm(array $form): array { | ||||
| $this->categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | $this->categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | ||||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups(null, null); | |||||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups(null, false); | |||||
| $selected = []; | $selected = []; | ||||
| /* @var $enabledGroup EnabledGroup */ | /* @var $enabledGroup EnabledGroup */ | ||||
| foreach ($enabledGroups as $enabledGroup) { | foreach ($enabledGroups as $enabledGroup) { |
| public function getEnableCategoriesForm(array $form, int $mid, int $sheetSettingId): array { | public function getEnableCategoriesForm(array $form, int $mid, int $sheetSettingId): array { | ||||
| $categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | $categories = $this->getCategoryFactory()->findAllActive('name', 'ASC'); | ||||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSettingId, null); | |||||
| $enabledGroups = $this->getEnabledGroupFactory()->findAllEnabledGroups($sheetSettingId, false); | |||||
| $selected = []; | $selected = []; | ||||
| /* @var $enabledGroup EnabledGroup */ | /* @var $enabledGroup EnabledGroup */ | ||||
| foreach ($enabledGroups as $enabledGroup) { | foreach ($enabledGroups as $enabledGroup) { | ||||
| unset($enabled[$key]); | unset($enabled[$key]); | ||||
| } | } | ||||
| } | } | ||||
| $this->getEnabledGroupFactory()->updateSheetSettingsEnabledGroups($this->sheetSettingId, $enabled); | |||||
| $this->getEnabledGroupFactory()->updateSheetSettingsEnabledGroups($this->sheetSettingId, $enabled, false); | |||||
| $this->getCacheService()->resetCache([ | $this->getCacheService()->resetCache([ | ||||
| 'arlista_product_uploaded_list_form', $this->mid, $this->sheetSettingId, 'enabled_categories']); | 'arlista_product_uploaded_list_form', $this->mid, $this->sheetSettingId, 'enabled_categories']); | ||||
| \Drupal::messenger()->addStatus('Sikeres mentés!'); | \Drupal::messenger()->addStatus('Sikeres mentés!'); |
| $enabledComponents[$component->getId()] = $component; | $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->manufacturersList = $this->getComponentManufacturersList($enabledComponents); | ||||
| $this->enabledComponents = $enabledComponents; | $this->enabledComponents = $enabledComponents; | ||||
| //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), | //$this->getCacheService()->setCachedDataByName([$this->getFormId(), $manufacturer->getId(), |