Skip to content

Commit

Permalink
add fixtures new fields
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel8702 committed Apr 16, 2021
1 parent 0dcb6fc commit bb5aca6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
6 changes: 6 additions & 0 deletions src/Fixture/CatalogFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
->children()
->scalarNode('starts_at')->defaultNull()->end()
->scalarNode('ends_at')->defaultNull()->end()
->scalarNode('template')->defaultValue('@BitBagSyliusCatalogPlugin/Catalog/Templates/showProducts.html.twig')->end()
->arrayNode('translations')
->prototype('array')
->children()
Expand All @@ -72,6 +73,11 @@ protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void
->end()
->end()
->enumNode('associated_products_rules_operator')->values([RuleInterface::AND, RuleInterface::OR])->end()
->enumNode('sorting_type')->values(['newest', 'oldest', 'most_wishlist', 'cheapest', 'most_expensive', 'bestsellers'])->end()
->integerNode('display_products')
->min(1)
->max(12)
->end()
->end()
->end()
->end()
Expand Down
7 changes: 7 additions & 0 deletions src/Fixture/Factory/CatalogFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ private function createCatalog(string $code, array $catalogData): void
$catalog->setEndDate(new \DateTime($catalogData['ends_at']));
}

if (!empty($catalogData['template'])) {
$catalog->setTemplate($catalogData['template']);
}

foreach ($catalogData['translations'] as $localeCode => $translation) {
/** @var CatalogTranslationInterface $catalogTranslation */
$catalogTranslation = $this->catalogTranslationFactory->createNew();
Expand All @@ -85,6 +89,9 @@ private function createCatalog(string $code, array $catalogData): void
$this->createRule($rule, CatalogRule::TARGET_PRODUCT_ASSOCIATION, $catalog);
}

$catalog->setSortingType(($catalogData['sorting_type']));
$catalog->setDisplayProducts(($catalogData['display_products']));

$this->catalogRepository->add($catalog);
}

Expand Down
5 changes: 4 additions & 1 deletion src/Form/Type/Translation/CatalogTranslationType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ class CatalogTranslationType extends AbstractResourceType
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('name', TextType::class, ['label' => 'bitbag_sylius_catalog_plugin.ui.name']);
->add('name', TextType::class, [
'label' => 'bitbag_sylius_catalog_plugin.ui.name',
])
;
}
}
3 changes: 2 additions & 1 deletion src/Resources/config/doctrine/Catalog.orm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</id>
<field name="startDate" column="start_date" type="datetime" nullable="true"/>
<field name="endDate" column="end_date" type="datetime" nullable="true"/>
<field name="code" column="code" type="string" nullable="true"/>
<field name="code" column="code" nullable="true" unique="true"/>
<field name="connectingRules" column="connecting_rules" type="string" />
<field name="productAssociationConnectingRules" column="product_connecting_rules" type="string" />
<field name="template" column="template" />
Expand All @@ -26,5 +26,6 @@
<cascade-all />
</cascade>
</one-to-many>

</mapped-superclass>
</doctrine-mapping>
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
<tag name="bitbag_sylius_catalog_plugin.catalog_sort_checker" type="most_expensive" label="bitbag_sylius_catalog_plugin.ui.form.catalog.most_expensive" />
</service>

<service id="bit_bag.sylius_catalog_plugin.checker.sort.elasticsearch.newest_sort" class="BitBag\SyliusCatalogPlugin\Checker\Sort\Elasticsearch\NewestSort">
<service id="bitbag_sylius_catalog_plugin.checker.sort.elasticsearch.newest_sort" class="BitBag\SyliusCatalogPlugin\Checker\Sort\Elasticsearch\NewestSort">
<argument>%bitbag_es_shop_product_created_at%</argument>
<tag name="bitbag_sylius_catalog_plugin.catalog_sort_checker" type="newest" label="bitbag_sylius_catalog_plugin.ui.form.catalog.newest" />
</service>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ sylius_fixtures:
rules_operator: And
associated_products_rules: []
associated_products_rules_operator: And
template: '@BitBagSyliusCatalogPlugin/Catalog/Templates/showProducts.html.twig'
sorting_type: 'newest'
display_products: 12

0 comments on commit bb5aca6

Please sign in to comment.