magento2-functional-testing-framework
magento2-functional-testing-framework copied to clipboard
Set custom product attributes
There seems to be no documentation on how to set custom product attributes through entity data. I searched through the example tests and tried a few things to no avail.
Preconditions
- MFTF v3
Steps to reproduce
- Create custom attribute entity
<entity name="SubscriptionIsEnabled" type="custom_attribute">
<data key="attribute_code">sub_enabled</data>
<data key="value">1</data>
</entity>
- Create a product entity
<entity name="SubscriptionProduct" extends="SimpleProduct">
<data key="name">Simple Subscription</data>
<data key="sku" unique="suffix">simple-trial-2</data>
<data key="urlKey" unique="suffix">simple-trial-2</data>
<requiredEntity type="custom_attribute">SubscriptionIsEnabled</requiredEntity>
</entity>
- Create the product in a
<before>
block of a Suite
<createData entity="SubscriptionProduct" stepKey="createSubscriptionProduct">
<requiredEntity createDataKey="createCategory"/>
</createData>
Expected result
- The product's sub_enabled custom attribute should be set
Actual result
- The attribute is not set
Hi @snez. Thank you for your report. To help us process this issue please make sure that you provided sufficient information.
Please, add a comment to assign the issue: @magento I am working on this
- Join Magento Community Engineering Slack and ask your questions in #github channel.
@snez Ran into this as well trying to set product custom attribute on product test entity. Using custom_attribute_array
instead of custom_attribute
for type worked in my case for a "yes/no" custom attribute
<entity name="SubscriptionProduct" extends="SimpleProduct">
<data key="name">Simple Subscription</data>
<data key="sku" unique="suffix">simple-trial-2</data>
<data key="urlKey" unique="suffix">simple-trial-2</data>
- <requiredEntity type="custom_attribute">SubscriptionIsEnabled</requiredEntity>
+ <requiredEntity type="custom_attribute_array">SubscriptionIsEnabled</requiredEntity>
</entity>