-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shopsys] out of stock products behavior (#3587)
- Loading branch information
Showing
13 changed files
with
370 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\ProductFeed\LuigisBoxBundle\Form; | ||
|
||
use Shopsys\FrameworkBundle\Component\Domain\AdminDomainTabsFacade; | ||
use Shopsys\FrameworkBundle\Component\Setting\Setting; | ||
use Shopsys\Plugin\PluginCrudExtensionInterface; | ||
use Shopsys\ProductFeed\LuigisBoxBundle\Model\Setting\LuigisBoxFeedSettingEnum; | ||
|
||
class LuigisBoxCrudExtension implements PluginCrudExtensionInterface | ||
{ | ||
/** | ||
* @param \Shopsys\FrameworkBundle\Component\Setting\Setting $setting | ||
* @param \Shopsys\ProductFeed\LuigisBoxBundle\Model\Setting\LuigisBoxFeedSettingEnum $luigisBoxFeedSettingEnum | ||
* @param \Shopsys\FrameworkBundle\Component\Domain\AdminDomainTabsFacade $adminDomainTabsFacade | ||
*/ | ||
public function __construct( | ||
protected readonly Setting $setting, | ||
protected readonly LuigisBoxFeedSettingEnum $luigisBoxFeedSettingEnum, | ||
protected readonly AdminDomainTabsFacade $adminDomainTabsFacade, | ||
) { | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormTypeClass(): string | ||
{ | ||
return LuigisBoxSettingFormType::class; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getFormLabel(): string | ||
{ | ||
return t('Luigi\'s Box settings'); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function getData($id): array | ||
{ | ||
$data = []; | ||
|
||
foreach ($this->luigisBoxFeedSettingEnum->getAllCases() as $settingName) { | ||
$data[$settingName] = $this->setting->getForDomain($settingName, $this->adminDomainTabsFacade->getSelectedDomainId()); | ||
} | ||
|
||
return $data; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function saveData($id, $data): void | ||
{ | ||
foreach ($data as $name => $value) { | ||
$this->setting->setForDomain($name, $value, $this->adminDomainTabsFacade->getSelectedDomainId()); | ||
} | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function removeData($id): void | ||
{ | ||
foreach ($this->luigisBoxFeedSettingEnum->getAllCases() as $settingName) { | ||
$this->setting->deleteByName($settingName); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\ProductFeed\LuigisBoxBundle\Form; | ||
|
||
use Shopsys\FrameworkBundle\Form\MessageType; | ||
use Shopsys\ProductFeed\LuigisBoxBundle\Model\Setting\LuigisBoxFeedSettingEnum; | ||
use Symfony\Component\Form\AbstractType; | ||
use Symfony\Component\Form\Extension\Core\Type\IntegerType; | ||
use Symfony\Component\Form\FormBuilderInterface; | ||
use Symfony\Component\Validator\Constraints; | ||
|
||
class LuigisBoxSettingFormType extends AbstractType | ||
{ | ||
/** | ||
* @param \Symfony\Component\Form\FormBuilderInterface $builder | ||
* @param array $options | ||
*/ | ||
public function buildForm(FormBuilderInterface $builder, array $options): void | ||
{ | ||
$builder | ||
->add(LuigisBoxFeedSettingEnum::LUIGIS_BOX_RANK, IntegerType::class, [ | ||
'label' => t('Luigi\'s Box rank'), | ||
'required' => true, | ||
'constraints' => [ | ||
new Constraints\NotNull([ | ||
'message' => 'Please enter the Luigi\'s Box rank.', | ||
]), | ||
new Constraints\Range(['min' => 1, 'max' => 15]), | ||
], | ||
]) | ||
->add('luigisBoxRankInfo', MessageType::class, [ | ||
'message_level' => MessageType::MESSAGE_LEVEL_INFO, | ||
'data' => t('The value is used for availability_rank setting in Luigi\'s Box feed. See <a href="https://docs.luigisbox.com/indexing/feeds.html">the docs</a> for more information.'), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\ProductFeed\LuigisBoxBundle\Migrations; | ||
|
||
use Doctrine\DBAL\Schema\Schema; | ||
use Shopsys\FrameworkBundle\Migrations\MultidomainMigrationTrait; | ||
use Shopsys\MigrationBundle\Component\Doctrine\Migrations\AbstractMigration; | ||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | ||
|
||
class Version20241113193905 extends AbstractMigration implements ContainerAwareInterface | ||
{ | ||
use MultidomainMigrationTrait; | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function up(Schema $schema): void | ||
{ | ||
foreach ($this->getAllDomainIds() as $domainId) { | ||
$this->sql('INSERT INTO setting_values (name, domain_id, value, type) VALUES (:name, :domainId, :value, :type)', [ | ||
'domainId' => $domainId, | ||
'name' => 'luigisBoxRank', | ||
'value' => 7, | ||
'type' => 'integer', | ||
]); | ||
} | ||
} | ||
|
||
/** | ||
* @param \Doctrine\DBAL\Schema\Schema $schema | ||
*/ | ||
public function down(Schema $schema): void | ||
{ | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
src/Model/Setting/Exception/LuigisBoxSettingNotFoundException.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\ProductFeed\LuigisBoxBundle\Model\Setting\Exception; | ||
|
||
use Exception; | ||
|
||
class LuigisBoxSettingNotFoundException extends Exception | ||
{ | ||
/** | ||
* @param array $criteria | ||
*/ | ||
public function __construct(array $criteria) | ||
{ | ||
$message = sprintf('LuigisBoxSetting not found for criteria: %s', json_encode($criteria)); | ||
|
||
parent::__construct($message); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\ProductFeed\LuigisBoxBundle\Model\Setting; | ||
|
||
use Shopsys\FrameworkBundle\Component\Enum\AbstractEnum; | ||
|
||
class LuigisBoxFeedSettingEnum extends AbstractEnum | ||
{ | ||
public const string LUIGIS_BOX_RANK = 'luigisBoxRank'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
msgid "" | ||
msgstr "" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Language: cs\n" | ||
|
||
msgid "Please enter the Luigi's Box rank." | ||
msgstr "Zadejte prosím Luigi's Box rank" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
msgid "" | ||
msgstr "" | ||
"Content-Type: text/plain; charset=UTF-8\n" | ||
"Content-Transfer-Encoding: 8bit\n" | ||
"Language: en\n" | ||
|
||
msgid "Please enter the Luigi's Box rank." | ||
msgstr "" | ||
|
Oops, something went wrong.