minor #12344 [Product][Association] Fix attaching association with numeric code (hatem20)

This PR was merged into the 1.12 branch.

Discussion
----------


| Q               | A
| --------------- | -----
| Branch?         | 1.12
| Bug fix?        | yes
| New feature?    | no
| BC breaks?      | no
| Deprecations?   | no
| Related tickets | fixes #12339
| License         | MIT

<!--
 - Bug fixes must be submitted against the 1.7 or 1.8 branch (the lowest possible)
 - Features and deprecations must be submitted against the master branch
 - Make sure that the correct base branch is set

 To be sure you are not breaking any Backward Compatibilities, check the documentation:
 https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html
-->


Commits
-------

0f62196135 [Product][Association] Fix attaching association with numeric code
This commit is contained in:
Jan Góralski 2023-04-07 12:58:55 +02:00 committed by GitHub
commit d07647620e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -37,3 +37,16 @@ Feature: Adding a new product with associations
And this product should have an association "Accessories" with product "LG headphones"
And this product should not have an association "Accessories" with product "LG earphones"
And the product "LG G3" should appear in the store
@ui @javascript
Scenario: Adding a new product with association with numeric code
Given the store has 123 product association type
When I want to create a new simple product
And I specify its code as "lg_g3"
And I name it "LG G3" in "English (United States)"
And I set its price to "$400.00" for "United States" channel
And I associate as 123 the "LG headphones" and "LG earphones" products
And I add it
Then I should be notified that it has been successfully created
And this product should have an association 123 with products "LG headphones" and "LG earphones"
And the product "LG G3" should appear in the store

View file

@ -71,6 +71,14 @@ final class ProductAssociationContext implements Context
}
}
/**
* @Given the store has :firstName product association type
*/
public function theStoreHasProductAssociationType($name)
{
$this->createProductAssociationType($name);
}
/**
* @Given /^the (product "[^"]+") has(?:| also) an (association "[^"]+") with (product "[^"]+")$/
*/

View file

@ -75,7 +75,7 @@ final class ProductsToProductAssociationsTransformer implements DataTransformerI
}
/** @var ProductAssociationInterface $productAssociation */
$productAssociation = $this->getProductAssociationByTypeCode($productAssociationTypeCode);
$productAssociation = $this->getProductAssociationByTypeCode((string) $productAssociationTypeCode);
$this->setAssociatedProductsByProductCodes($productAssociation, $productCodes);
$productAssociations->add($productAssociation);
}