How to get entity type link field value in Magento 2 Commerce?

In Magento commerce, Retrieve the value of the link field for the specific entity type programmatically to join database query.

Magento uses $metadata->getLinkField() to get the name of the field for the given entity type using MetadataPool class.

You need to pass the entity type interface to fetch the link field name. When you working with Magento commerce, you required entity link field value instead of table primary key entity_id to join query with other database tables.

echo $linkFieldValue = $this->getLinkField($);

You can pass an interface value to retrieve the link field for the given entity type, for a category, Magento\Catalog\Api\Data\CategoryInterface or rule, Magento\SalesRule\Api\Data\RuleInterface.

row_id is the link field used to Content Staging M2 Commerce functionality.

Output:
row_id

Leave a Reply