magento / magento/magento2-functional-testing-framework

Set custom product attributes

Open
#831 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
PHP
Stars
154
Forks
134
PR merge metrics
No merged PRs in 30d

Description

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
  1. MFTF v3
Steps to reproduce
  1. Create custom attribute entity
    <entity name="SubscriptionIsEnabled" type="custom_attribute">
        <data key="attribute_code">sub_enabled</data>
        <data key="value">1</data>
    </entity>
  1. 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>
  1. Create the product in a <before> block of a Suite
    <createData entity="SubscriptionProduct" stepKey="createSubscriptionProduct">
        <requiredEntity createDataKey="createCategory"/>
    </createData>
Expected result
  1. The product's sub_enabled custom attribute should be set
Actual result
  1. The attribute is not set

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the MFTF v3 entity examples and tests for custom_attribute entities, then trace how the createData step in a Suite before block applies product data. Document the working syntax for setting a product custom attribute through entity data, including the requiredEntity relationship, and verify that the sub_enabled attribute is set on the created product.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.