SELECT 
  cscart_products_categories.product_id, 
  GROUP_CONCAT(
    IF(
      cscart_products_categories.link_type = "M", 
      CONCAT(
        cscart_products_categories.category_id, 
        "M"
      ), 
      cscart_products_categories.category_id
    )
  ) AS category_ids, 
  product_position_source.position AS position 
FROM 
  cscart_products_categories 
  INNER JOIN cscart_categories ON cscart_categories.category_id = cscart_products_categories.category_id 
  AND cscart_categories.storefront_id IN (0, 1) 
  AND (
    cscart_categories.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_categories.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_categories.usergroup_ids
    )
  ) 
  AND cscart_categories.status IN ('A', 'H') 
  LEFT JOIN cscart_products_categories AS product_position_source ON cscart_products_categories.product_id = product_position_source.product_id 
  AND product_position_source.category_id = 304 
WHERE 
  cscart_products_categories.product_id IN (
    122330, 133778, 146242, 130403, 120464, 
    137235, 158252, 135956, 162915, 124934, 
    158535, 173481, 151549, 167453, 172324, 
    147362, 149707, 125585, 120426, 166942, 
    124196, 123357, 177999, 137550, 157189, 
    161753, 128544, 151672, 170490, 168486, 
    142199, 124209
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00187

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.162930877,
    "nested_loop": [
      {
        "table": {
          "table_name": "cscart_products_categories",
          "access_type": "range",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "pt",
          "key_length": "3",
          "used_key_parts": ["product_id"],
          "loops": 1,
          "rows": 32,
          "cost": 0.05815448,
          "filtered": 100,
          "attached_condition": "cscart_products_categories.product_id in (122330,133778,146242,130403,120464,137235,158252,135956,162915,124934,158535,173481,151549,167453,172324,147362,149707,125585,120426,166942,124196,123357,177999,137550,157189,161753,128544,151672,170490,168486,142199,124209)",
          "using_index": true
        }
      },
      {
        "table": {
          "table_name": "cscart_categories",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "c_status", "p_category_id"],
          "key": "PRIMARY",
          "key_length": "3",
          "used_key_parts": ["category_id"],
          "ref": [
            "u985510652_ecartify_abhi.cscart_products_categories.category_id"
          ],
          "loops": 32,
          "rows": 1,
          "cost": 0.02944128,
          "filtered": 100,
          "attached_condition": "cscart_categories.storefront_id in (0,1) and (cscart_categories.usergroup_ids = '' or find_in_set(0,cscart_categories.usergroup_ids) or find_in_set(1,cscart_categories.usergroup_ids)) and cscart_categories.`status` in ('A','H')"
        }
      },
      {
        "table": {
          "table_name": "product_position_source",
          "access_type": "eq_ref",
          "possible_keys": ["PRIMARY", "pt"],
          "key": "PRIMARY",
          "key_length": "6",
          "used_key_parts": ["category_id", "product_id"],
          "ref": [
            "const",
            "u985510652_ecartify_abhi.cscart_products_categories.product_id"
          ],
          "loops": 32,
          "rows": 1,
          "cost": 0.05483648,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
120426 304M 0
120464 304M 0
122330 304M 0
123357 304M 0
124196 304M 0
124209 304M 0
124934 304M 0
125585 304M 0
128544 304M 0
130403 304M 0
133778 304M 0
135956 304M 0
137235 304M 0
137550 304M 0
142199 304M 0
146242 304M 0
147362 304M 0
149707 304M 0
151549 304M 0
151672 304M 0
157189 304M 0
158252 304M 0
158535 304M 0
161753 304M 0
162915 304M 0
166942 304M 0
167453 304M 0
168486 304M 0
170490 304M 0
172324 304M 0
173481 304M 0
177999 304M 0