4

Does Magento 2's "EE Catalog Staging" feature rename the entity_id column of the catalog_product_entity_datetime table to row_id?

An old client recently reached out to me to say, after upgrading to Magento 2.1.1 with the EE Catalog Staging feature, that they're seeing the following errors related to some custom code.

Column not found: 1054 Unknown column 'main_table.entity_id' in 'field list'

and tell me their catalog_product_entity_datetime table's entity_id column is gone, replaced by a row_id column.

+--------------+----------------------+------+-----+---------+----------------+
| Field        | Type                 | Null | Key | Default | Extra          |
+--------------+----------------------+------+-----+---------+----------------+
| value_id     | int(11)              | NO   | PRI | NULL    | auto_increment |
| attribute_id | smallint(5) unsigned | NO   | MUL | 0       |                |
| store_id     | smallint(5) unsigned | NO   | MUL | 0       |                |
| row_id       | int(10) unsigned     | NO   | MUL | NULL    |                |
| value        | datetime             | YES  |     | NULL    |                |
+--------------+----------------------+------+-----+---------+----------------+

I"m (obviously) following up with my client on this one for more information -- but is this true? Did Magento EE initiate a schema change here?

1
  • In which situation the entity_id and row_id are different ?
    – devhs
    Jun 16, 2021 at 9:08

2 Answers 2

4

Yes, Magento EE Staging modules change the schema on install. See: app/code/Magento/CatalogStaging/Setup/InstallSchema.php for datails.

4
  • Thank you @KAndy -- do you know if there's a reason for that? Lacking context is seems — reckless — for a seemingly arbitrary change to tables that have been stable for more than half a decade. Oct 6, 2016 at 19:29
  • Staging adds MVCC to product, category, rules, etc. entities. It adds row_id, created_in, updated_in to all entities. But because attribute value belongs to concrete version entity_id field was replaced on row_id.
    – KAndy
    Oct 6, 2016 at 19:59
  • In which situation the entity_id and row_id are different ?
    – devhs
    Jun 16, 2021 at 9:08
  • entity_id and row_id are different when you have more than one version of an entity
    – KAndy
    Jun 22, 2021 at 3:16
7

I can't reference the code on account of EE licensing, but in short: Yes. Magento Enterprise Edition 2.1.0 introduced a new 'content staging' feature, which involves some quite invasive changes to the core database schema.

Among other things, all entity_id/product_id/child_id columns in catalog_category_entity* and catalog_product_entity* tables are changed to row_id. There are similar changes across marketing-related content types. Staging covers categories, products, CMS, promotions, and more.

The changes are not arbitrary. They did not literally change entity_id to row_id. The entity IDs still exist, just in a different relation table. What they did was add a layer of abstraction such that changes (to any given content covered by the feature) can be batched and scheduled. You make content changes and add them to a batch, then at the appointed time Magento puts all of them live simultaneously. This is an evolution of some of the basic scheduling functionality that's been present for designs, banners, promo rules, etc. for a long time.

As to changing core table schemas to accomplish this, don't ask me why they chose this approach.

2
  • In which situation the entity_id and row_id are different ?
    – devhs
    Jun 16, 2021 at 9:09
  • 1
    @devhs: If you use content staging for a record, you will have multiple rows with different row_ids but a shared entity_id.
    – Ryan Hoerr
    Jun 17, 2021 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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