diff --git a/.github/workflows/behat_ui.yml b/.github/workflows/behat_ui.yml index c810302c48..8c25c99e33 100644 --- a/.github/workflows/behat_ui.yml +++ b/.github/workflows/behat_ui.yml @@ -33,6 +33,7 @@ jobs: PIMCORE_INSTALL_MYSQL_PORT: "3306" PANTHER_EXTERNAL_BASE_URI: "http://localhost:9080/index_test.php" PANTHER_CHROME_ARGUMENTS: "--disable-dev-shm-usage" + PANTHER_DEVTOOLS: "0" PIMCORE_KERNEL_CLASS: 'Kernel' strategy: diff --git a/docs/03_Bundles/Menu_Bundle.md b/docs/03_Bundles/Menu_Bundle.md index c5f34feb0f..5277296c8a 100644 --- a/docs/03_Bundles/Menu_Bundle.md +++ b/docs/03_Bundles/Menu_Bundle.md @@ -37,7 +37,7 @@ public function registerBundlesToCollection(BundleCollection $collection) ```php Many models in CoreShop are extended in the Core component. If the model you are willing to override exists in the -> Core you should be extending the Core one, not the base model from the component. +> Many models in CoreShop are extended in the Core component. If the model you are willing to override exists in the Core you should be extending the Core one, not the base model from the component. ## How to Customize a Model -First things first: If you want to extend coreshop models your Bundle must extend the `AbstractResourceBundle`. Next you -have set your supported drivers. Just add the following lines of code to your bundle class: +### Doctrine ORM -```php -public function getSupportedDrivers(): array -{ -return [ -CoreShopResourceBundle::DRIVER_DOCTRINE_ORM -]; -} -``` - -After that have to tell the bundle where your models are. For that, add the override the following method in your bundle -class and return the model namespace. Here is an example for the `AppBundle`: +Depending on your Doctrine ORM configuration, you need to place your Models in the right Folder. The Default configuration, places them in the `Entity` directory: -```php -protected function getModelNamespace(): string -{ -return "AppBundle\Model"; -} +```yaml +doctrine: + orm: + mappings: + App: + type: attribute + dir: '%kernel.project_dir%/src/App/Entity' + is_bundle: false + prefix: App\Entity + alias: App ``` -Here a quick overview for you which directories are important for you, when customizing CoreShop models. +### Example Model -| Folder | Description | -|-------------------------------------------|-----------------------------------------------| -| `AcmeBundle/Model` or `AcmeBundle/Entity` | Where your models are living | -| `AcmeBundle/config/doctrine/model` | Put your doctrine `.yml` config files in here | -| `AcmeBundle/config/serializer` | The serializer configs for the models | - -Let’s take the `CoreShop\Component\Currency\Model\Currency` as an example. This one is extended in Core. How can you -check that? +Let’s take the [```CoreShop\Component\Currency\Model\Currency```](https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Component/Currency/Model/Currency.php) as an example. This one is extended in Core. How can you check that? First of all, you need to find the current used class by doing following: @@ -47,70 +32,57 @@ First of all, you need to find the current used class by doing following: $ php bin/console debug:container --parameter=coreshop.model.currency.class ``` -As a result you will get the `CoreShop\Component\Core\Model\Currency` - this is the class that you need to be extending. +As a result you will get the [```CoreShop\Component\Core\Model\Currency```](https://github.com/coreshop/CoreShop/blob/master/src/CoreShop/Component/Core/Model/Currency.php) - this is the class that you need to be extending. -Assuming you want to add a field called **flag**: +Assuming you want to add a field called **flag** -**1.** The first thing to do is to write your own class which will extend the base `Currency` class: +**1.** The first thing to do is to write your own class which will extend the base ```Currency``` class ```php flag; } - /** - * @param bool $flag - */ - public function setFlag($flag) + public function setFlag(bool $flag): void { $this->flag = $flag; } } ``` -**2.** Next define your entity’s mapping. The file should be placed -in `AppBundle/Resources/config/doctrine/Currency.orm.yml`: - -```yaml -AppBundle\Entity\Currency: - type: mappedSuperclass - table: coreshop_currency - fields: - flag: - type: boolean - nullable: true -``` +**2**. Finally you’ll need to override the model’s class in the ```config/config.yaml```. -**3.** Finally, you’ll need to override the model’s class in the `app/config/config.yml`. +Under the core_shop_* where * is the name of the bundle of the model you are customizing, in our case it will be the CoreShopCurrencyBundle -> core_shop_currency. -Under the `core_shop_currency`, modify as follows: ```yaml core_shop_currency: - resources: - currency: - classes: - model: AppBundle\Entity\Currency + resources: + currency: + classes: + model: App\Entity\Currency ``` -**4.** Update the database. There are two ways to do it: +**3**. Update the database. There are two ways to do it. via direct database schema update: @@ -118,9 +90,24 @@ via direct database schema update: $ php bin/console doctrine:schema:update --force ``` -via migrations (recommended): +via migrations: +Which we strongly recommend over updating the schema. ```bash $ php bin/console doctrine:migrations:diff $ php bin/console doctrine:migrations:migrate ``` + +**4**. We also need a serializer group for the new field. This is done in the ```config/jms_serializer/Currency.yaml``` file. + +```yaml +App\Entity\Currency: + exclusion_policy: ALL + xml_root_name: store + properties: + flag: + expose: true + type: bool + groups: [Detailed] + +``` \ No newline at end of file diff --git a/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md b/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md index ae25f9858f..48d415453a 100644 --- a/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md +++ b/docs/03_Development/01_Extending_Guide/02_Extend_CoreShop_Forms.md @@ -1,7 +1,7 @@ # Customizing Forms The forms in CoreShop are placed in the `CoreShop\Bundle\*BundleName*\Form\Type` namespaces and the extensions will be -placed in `AppBundle\Form\Extension`. +placed in `App\CoreShop\Form\Extension`. ## Why would you customize a Form? @@ -46,7 +46,7 @@ this is the class that you need to be extending. ```php add('some_value', TextType::class) -; + public function buildForm(FormBuilderInterface $builder, array $options): void + { + $builder->add('some_value', TextType::class); + } } ``` With configuration, comes a Javascript file as well: ```javascript -//AppBundle/Resources/public/pimcore/js/custom_condition.js +//public/coreshop/js/custom_condition.js pimcore.registerNS('coreshop.product.pricerule.conditions.custom'); coreshop.product.pricerule.conditions.custom = Class.create(coreshop.rules.conditions.abstract, { @@ -91,22 +87,14 @@ coreshop.product.pricerule.conditions.custom = Class.create(coreshop.rules.condi }); ``` -Don't forget to run the following command afterwards to deploy it if needed. If you're using the latest symfony -structure, omit the `web`. - -```php -bin/console assets:install -``` - ## Registering the Custom Condition to the Container and load the Javascript File We now need to create our Service Definition for our Custom Condition: ```yaml -app.product_price_rule.custom_condition: - class: AppBundle\CoreShop\CustomCondition +App\CoreShop\CustomCondition: tags: - - { name: coreshop.product_price_rule.condition, type: custom, form-type: AppBundle\Form\Type\CustomConditionType } + - { name: coreshop.product_price_rule.condition, type: custom, form-type: App\CoreShop\Form\Type\CustomConditionType } ``` and add this to your config.yml: @@ -115,4 +103,4 @@ and add this to your config.yml: core_shop_product: pimcore_admin: js: - custom_condition: '/bundles/app/pimcore/js/custom_condition.js' + custom_condition: '/coreshop/js/custom_condition.js' diff --git a/docs/03_Development/02_Localization/02_Countries/02_Context.md b/docs/03_Development/02_Localization/02_Countries/02_Context.md index d8a1e27fbb..bbbdbd1a09 100644 --- a/docs/03_Development/02_Localization/02_Countries/02_Context.md +++ b/docs/03_Development/02_Localization/02_Countries/02_Context.md @@ -58,13 +58,12 @@ And configure the service: ```yaml services: -app.coreshop.country.context.request.document_based: -class: AppBundle\CoreShop\Address\Context\DocumentBasedRequestRequestResolver -arguments: - - '@Pimcore\Http\Request\Resolver\DocumentResolver' - - '@coreshop.repository.country' -tags: - - { name: coreshop.context.country.request_based.resolver } + App\CoreShop\Address\Context\DocumentBasedRequestRequestResolver: + arguments: + - '@Pimcore\Http\Request\Resolver\DocumentResolver' + - '@coreshop.repository.country' + tags: + - { name: coreshop.context.country.request_based.resolver } ``` CoreShop will now resolve the current country based on the Pimcore site being accessed. diff --git a/docs/03_Development/03_Products/02_Price_Calculation.md b/docs/03_Development/03_Products/02_Price_Calculation.md index 4f1d0d2be8..f599e3ec6d 100644 --- a/docs/03_Development/03_Products/02_Price_Calculation.md +++ b/docs/03_Development/03_Products/02_Price_Calculation.md @@ -45,7 +45,7 @@ the Discount. Note that this example is a demonstration and not a practical impl $data->getCurrency()?->getId(), 'name' => $data->getCurrency()?->getName(), 'isoCode' => $data->getCurrency()?->getIsoCode(), - ] + ], ]; } diff --git a/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php new file mode 100644 index 0000000000..f505664355 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Pimcore/Renderer/StockOnHandRenderer.php @@ -0,0 +1,42 @@ +twig->render('@CoreShopInventory/pimcore/stock_text.html.twig', [ + 'stockable' => $object, + ]); + } +} diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml index f3da17f5f9..af6e564928 100755 --- a/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/config/services.yml @@ -17,3 +17,7 @@ services: - '@CoreShop\Component\Inventory\Checker\AvailabilityCheckerInterface' tags: - { name: twig.extension } + + CoreShop\Bundle\InventoryBundle\Pimcore\Renderer\StockOnHandRenderer: + arguments: + - '@twig' \ No newline at end of file diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml new file mode 100644 index 0000000000..d2ac590890 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.de.yml @@ -0,0 +1,6 @@ +coreshop: + inventory: + stock: + on_hand: 'Verfügbare Lagerbestände: %on_hand%' + on_hold: 'Reservierte Lagerbestände: %on_hold%' + not_tracked: 'Lagerbestände nicht verfolgt' diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml new file mode 100644 index 0000000000..60ca2cb7b5 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/translations/messages.en.yml @@ -0,0 +1,6 @@ +coreshop: + inventory: + stock: + on_hand: 'Available Stock on Hand: %on_hand%' + on_hold: 'Reserved Stock: %on_hold%' + not_tracked: 'Stock not tracked' diff --git a/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig new file mode 100644 index 0000000000..ebff282407 --- /dev/null +++ b/src/CoreShop/Bundle/InventoryBundle/Resources/views/pimcore/stock_text.html.twig @@ -0,0 +1,9 @@ +{% if stockable.isTracked %} +