Skip to content

Commit

Permalink
[shopsys] moved two attributes of ProductFormType from project-base t…
Browse files Browse the repository at this point in the history
…o framework (#3376)

Co-authored-by: stanoMilan <35031880+stanoMilan@users.noreply.github.com>
  • Loading branch information
TomasLudvik and stanoMilan authored Aug 27, 2024
1 parent dc4e1f5 commit b686cf0
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 1 deletion.
29 changes: 28 additions & 1 deletion src/Form/Admin/Product/ProductFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Shopsys\FrameworkBundle\Component\Plugin\PluginCrudExtensionFacade;
use Shopsys\FrameworkBundle\Form\Admin\Product\Parameter\ProductParameterValueFormType;
use Shopsys\FrameworkBundle\Form\Admin\Product\Price\ProductPricesWithVatSelectType;
use Shopsys\FrameworkBundle\Form\Admin\Stock\ProductStockFormType;
use Shopsys\FrameworkBundle\Form\CategoriesType;
use Shopsys\FrameworkBundle\Form\Constraints\UniqueProductParameters;
use Shopsys\FrameworkBundle\Form\DatePickerType;
Expand Down Expand Up @@ -38,6 +39,7 @@
use Shopsys\FrameworkBundle\Model\Seo\SeoSettingFacade;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\FormType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
Expand Down Expand Up @@ -115,6 +117,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$builder->add($this->createBasicInformationGroup($builder, $product, $disabledItemInMainVariantAttr));
$builder->add($this->createDisplayAvailabilityGroup($builder, $product));
$builder->add($this->createPricesGroup($builder, $product));
$builder->add($this->createStocksGroup($builder));
$builder->add($this->createDescriptionsGroup($builder, $product));
$builder->add($this->createShortDescriptionsGroup($builder, $product));
$builder->add($this->createShortDescriptionsUspGroup($builder));
Expand Down Expand Up @@ -363,6 +366,12 @@ private function createDisplayAvailabilityGroup(
'label' => t('Hide product'),
]);

$builderDisplayAvailabilityGroup->add('domainHidden', MultidomainType::class, [
'label' => t('Hide on domain'),
'required' => false,
'entry_type' => YesNoType::class,
]);

$builderDisplayAvailabilityGroup
->add('sellingFrom', DatePickerType::class, [
'required' => false,
Expand All @@ -388,7 +397,6 @@ private function createDisplayAvailabilityGroup(
'label' => t('Exclude from sale on domains'),
'required' => false,
'entry_type' => YesNoType::class,
'position' => ['after' => 'sellingDenied'],
]);

if (
Expand Down Expand Up @@ -465,6 +473,25 @@ private function createDisplayAvailabilityGroup(
return $builderDisplayAvailabilityGroup;
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
* @return \Symfony\Component\Form\FormBuilderInterface
*/
private function createStocksGroup(FormBuilderInterface $builder)
{
$stockGroupBuilder = $builder->create('stocksGroup', GroupType::class, [
'label' => t('Warehouses'),
]);

$stockGroupBuilder->add('productStockData', CollectionType::class, [
'required' => false,
'entry_type' => ProductStockFormType::class,
'render_form_row' => false,
]);

return $stockGroupBuilder;
}

/**
* @param \Symfony\Component\Form\FormBuilderInterface $builder
* @param \Shopsys\FrameworkBundle\Model\Product\Product|null $product
Expand Down
4 changes: 4 additions & 0 deletions src/Model/Product/ProductDataFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ protected function fillNew(ProductData $productData): void
$productData->name[$locale] = null;
$productData->variantAlias[$locale] = null;
}

$this->fillProductStockByStocks($productData);
}

/**
Expand Down Expand Up @@ -181,6 +183,8 @@ protected function fillFromProduct(ProductData $productData, Product $product):
$productData->pluginData = $this->pluginDataFormExtensionFacade->getAllData('product', $product->getId());
$productData->weight = $product->getWeight();
$productData->files = $this->uploadedFileDataFactory->createByEntity($product);

$this->fillProductStockByProduct($productData, $product);
}

/**
Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.cs.po
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,9 @@ msgstr "Skrýt"
msgid "Hide advertisement"
msgstr "Skrýt reklamu"

msgid "Hide on domain"
msgstr "Skrýt na doméně"

msgid "Hide product"
msgstr "Skrýt zboží"

Expand Down Expand Up @@ -3760,6 +3763,9 @@ msgstr "Nastavení %domainName% skladů uloženo."
msgid "Warehouse settings"
msgstr "Nastavení skladů"

msgid "Warehouses"
msgstr "Sklady"

msgid "Warehouses - full"
msgstr "Sklady - vše"

Expand Down
6 changes: 6 additions & 0 deletions src/Resources/translations/messages.en.po
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,9 @@ msgstr ""
msgid "Hide advertisement"
msgstr ""

msgid "Hide on domain"
msgstr ""

msgid "Hide product"
msgstr ""

Expand Down Expand Up @@ -3760,6 +3763,9 @@ msgstr ""
msgid "Warehouse settings"
msgstr ""

msgid "Warehouses"
msgstr ""

msgid "Warehouses - full"
msgstr ""

Expand Down

0 comments on commit b686cf0

Please sign in to comment.