Skip to content

Commit

Permalink
Merge branch '1.12' into 1.13
Browse files Browse the repository at this point in the history
* 1.12:
  Fix BC Break in SelectAttributeChoicesCollectionType
  [Admin] Add note to channel form about disabling account verification
  [Documentation] Add note about accessing guest orders by shop user
  Update docs/book/orders/checkout.rst
  Update checkout.rst
  Update upgrade file
  [Behat] Add scenario for checking if attribute is correctly added with values
  Use localeCode in ProductAttribute form to prevent logic from breaking when not using default locale
  Remove usage of defaultLocaleCode from SelectAttributeChoicesCollectionType
  • Loading branch information
GSadee committed Aug 18, 2023
2 parents 509a6f7 + 649a68b commit 61ffae5
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 7 deletions.
6 changes: 6 additions & 0 deletions UPGRADE-1.12.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# UPGRADE FROM `v1.12.9` TO `v1.12.10`

1. The `Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\SelectAttributeChoicesCollectionType` only
constructor argument has been made optional and is `null` by default, subsequently the first argument of
`sylius.form.type.attribute_type.select.choices_collection` has been removed.

# UPGRADE FROM `v1.12.8` TO `v1.12.9`

1. The `Sylius\Component\Core\OrderProcessing\OrderPaymentProcessor` constructor has been changed:
Expand Down
5 changes: 5 additions & 0 deletions docs/book/customers/customer_and_shopuser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ They can visit and modify their account.
While creating new account the existence of the provided email in the system is checked - if the email was present - it will already have a Customer
therefore the existing one will be assigned to the newly created ShopUser, if not - a new Customer will be created together with the ShopUser.

.. note::

Please note that if a newly created ShopUser has been assigned to an existing Customer, they will have access
to previously placed orders as a guest.

How to create a ShopUser programmatically?
''''''''''''''''''''''''''''''''''''''''''

Expand Down
2 changes: 1 addition & 1 deletion docs/book/orders/checkout.rst
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ How to perform the Addressing Step programmatically?

Firstly if the **Customer** is not yet set on the Order it will be assigned depending on the case:

* An already logged in **User** - the Customer is set for the Order using the `CartBlamerListener <https://github.com/Sylius/Sylius/blob/master/src/Sylius/Bundle/CoreBundle/EventListener/CartBlamerListener.php>`_, that determines the user basing on the event.
* An already logged in **User** - the Customer is set for the Order using the `ShopCartBlamerListener <https://github.com/Sylius/Sylius/blob/1.12/src/Sylius/Bundle/ShopBundle/EventListener/ShopCartBlamerListener.php>`_, that determines the user basing on the event.
* A **Customer** or **User** that was present in the system before (we've got their e-mail) - the Customer instance is updated via cascade, the order is assigned to it.
* A new **Customer** with unknown e-mail - a new Customer instance is created and assigned to the order.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@managing_product_attributes
Feature: Seeing correct select attribute values in different locale than default one
In order to see correct attribute values in different locale than default one
As an Administrator
I should be able to create attribute with values in different locale than default one

Background:
Given the store is available in "French (France)"
And I am logged in as an administrator

@ui @javascript
Scenario: Seeing correct attribute values in different locale than default one
When I want to create a new select product attribute
And I specify its code as "mug_material"
And I name it "Mug material" in "French (France)"
And I add value "Banana Skin" in "French (France)"
And I add it
Then I should be notified that it has been successfully created
And I should see the value "Banana Skin"
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,14 @@ public function theLastProductAttributeOnTheListShouldHave($name)
Assert::same(end($names), $name);
}

/**
* @Then I should see the value :value
*/
public function iShouldSeeTheValue(string $value): void
{
Assert::true($this->updatePage->hasAttributeValue($value));
}

/**
* @Then /^(this product attribute) should have value "([^"]*)"/
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ sylius:
ui:
catalog_promotion:
dates_details: This operation is time-consuming! Please consider a 2-10 minutes delay starting from the specified dates. The delay depends on the size of the catalog.
channel:
account_verification_required_details: By disabling this option, it will be possible to create accounts and access them without email verification and thus potentially access order data placed as a guest.
channel_pricing_history: 'Channel pricing history'
channel_pricings: Channel pricings
gateway:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@
{{ form_row(form.skippingShippingStepAllowed) }}
{{ form_row(form.skippingPaymentStepAllowed) }}
{{ form_row(form.accountVerificationRequired) }}
<small class="text gray ">{{ 'sylius.ui.channel.account_verification_required_details'|trans }}</small>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,13 @@

class SelectAttributeChoicesCollectionType extends AbstractType
{
private string $defaultLocaleCode;
private ?string $defaultLocaleCode = null;

public function __construct(TranslationLocaleProviderInterface $localeProvider)
public function __construct(?TranslationLocaleProviderInterface $localeProvider = null)
{
$this->defaultLocaleCode = $localeProvider->getDefaultLocaleCode();
if (null !== $localeProvider) {
$this->defaultLocaleCode = $localeProvider->getDefaultLocaleCode();
}
}

/**
Expand All @@ -48,7 +50,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
continue;
}

if (!array_key_exists($this->defaultLocaleCode, $values)) {
if ($this->defaultLocaleCode !== null && !array_key_exists($this->defaultLocaleCode, $values)) {
continue;
}

Expand Down Expand Up @@ -85,6 +87,11 @@ private function getUniqueKey(): string
return Uuid::uuid1()->toString();
}

/**
* @param array<array-key, mixed|null> $values
*
* @return array<string, mixed>
*/
private function resolveValues(array $values): array
{
$fixedValues = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
})
->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) {
$attributeValue = $event->getData();
$localeCode = $attributeValue['localeCode'];

if (!isset($attributeValue['attribute'])) {
return;
Expand All @@ -72,7 +73,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
return;
}

$this->addValueField($event->getForm(), $attribute);
$this->addValueField($event->getForm(), $attribute, $localeCode);
})
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
</service>

<service id="sylius.form.type.attribute_type.select.choices_collection" class="Sylius\Bundle\AttributeBundle\Form\Type\AttributeType\Configuration\SelectAttributeChoicesCollectionType">
<argument id="sylius.translation_locale_provider" type="service"/>
<tag name="form.type" />
</service>

Expand Down

0 comments on commit 61ffae5

Please sign in to comment.