cancel
Showing results for 
Search instead for 
Did you mean: 

How to get Media entity Id throught the Rest API

How to get Media entity Id throught the Rest API

Hello,

 

I'm using the rest API to sync my products.

After syncing my images I get a value_id as a response.

With this value_id i can't update my images because I need the entity_id.

 

These entity_ids are stored in the table: catalog_product_entity_media_gallery_value_to_entity.

But there is no way I can see to get these entity_ids.

 

Is there something I'm not seeing or how do I get the entity_id?

 

Thx,

Robin

 

1 REPLY 1

Re: How to get Media entity Id throught the Rest API

SELECT
  main.value_id,
  main.value AS FILE,
  main.media_type,
  entity.entity_id,
  VALUE.label,
  VALUE.position,
  VALUE.disabled,
  default_value.label AS label_default,
  default_value.position AS position_default,
  default_value.disabled AS disabled_default,
  value_video.provider AS video_provider,
  value_video.url AS video_url,
  value_video.title AS video_title,
  value_video.description AS video_description,
  value_video.metadata AS video_metadata,
  default_value_video.provider AS video_provider_default,
  default_value_video.url AS video_url_default,
  default_value_video.title AS video_title_default,
  default_value_video.description AS video_description_default,
  default_value_video.metadata AS video_metadata_default
FROM
  catalog_product_entity_media_gallery AS main
INNER JOIN
  catalog_product_entity_media_gallery_value_to_entity AS entity ON main.value_id = entity.value_id
LEFT JOIN
  catalog_product_entity_media_gallery_value AS VALUE ON main.value_id = VALUE.value_id AND entity.entity_id = VALUE.entity_id AND VALUE.store_id = 1
INNER JOIN
  catalog_product_entity_media_gallery_value AS default_value ON main.value_id = default_value.value_id AND default_value.entity_id = entity.entity_id AND default_value.store_id = 0
LEFT JOIN
  catalog_product_entity_media_gallery_value_video AS value_video ON VALUE.value_id = value_video.value_id AND VALUE.store_id = value_video.store_id
LEFT JOIN
  catalog_product_entity_media_gallery_value_video AS default_value_video ON default_value.value_id = default_value_video.value_id AND default_value.store_id = default_value_video.store_id
WHERE
  (main.attribute_id = '90') AND(main.disabled = 0) AND(entity.entity_id = '20977')
ORDER BY
  IF(
    VALUE.position IS NULL,
    default_value.position,
    VALUE.position
  ) ASC