I want to write a fixture for some products. The attribute my_attribute is of type eav/entity_attribute_source_table. The Options are not created by install scripts, so they are not in the test database.

How can I get EcomDev to create the needed options for my_attribute? I don't want to set a fixture on eav_attribute_option* tables because that would delete the options of all other attributes.

    - entity_id: 1
      sku: 359
      name: Product 1
      my_attribute: Option 1 #This option is to be generated
      type_id: simple
      price: 55
      visibility: 4
      status: 1
        - base

1 Answer 1


As far as I know you need to set a fixture on the eav_entity_attribute_option tables.

Since EcomDev_PHPUnit copies the database to a test table, your original database still will be intact, unless you have configured EcomDev_PHPUnit to use the original database (which is not a good idea). Because of this the truncation of the table should not be an issue.

If you need this complex fixtures, maybe it is easier to mock more of Magento to get around them?
Generally I try to avoid complex fixtures if possible.

  • Thanks! But there is no eav_entity_attribute_option table. Which ones do you mean exactly? Mocking the attribute options is also a nice idea, not sure how this would work though...
    – Simon
    Nov 18, 2014 at 10:20
  • Do table fixtures not truncate the table anymore when applied? Nov 18, 2014 at 10:27
  • @fschmengler just checked and can confirm that a table fixture on eav_attribute_option and eav_attribute_option_value truncates the tables.
    – Simon
    Nov 18, 2014 at 10:41
  • But the truncation only happens in the testing DB, not in your development db, so that shouldn't be an issue.
    – Vinai
    Nov 18, 2014 at 10:57
  • Learning to create mocks and to register them with Magento so they are used instead of the real things is a most valuable investment of time.
    – Vinai
    Nov 18, 2014 at 10:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.