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, 124886, 160305, 144198, 
    160560, 151873, 151844, 126598, 168881, 
    118657, 145090, 147385, 125755, 142280, 
    149363, 135432, 171144, 121051, 169683, 
    129203, 170791, 137428, 141350, 122326, 
    134524, 129552, 143235, 125593, 119689, 
    130340, 122179, 131962, 164157
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00123

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.324455446,
    "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": 64,
          "cost": 0.11551784,
          "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,124886,160305,144198,160560,151873,151844,126598,168881,118657,145090,147385,125755,142280,149363,135432,171144,121051,169683,129203,170791,137428,141350,122326,134524,129552,143235,125593,119689,130340,122179,131962,164157)",
          "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": 64,
          "rows": 1,
          "cost": 0.05806336,
          "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": 64,
          "rows": 1,
          "cost": 0.10967296,
          "filtered": 100
        }
      }
    ]
  }
}

Result

product_id category_ids position
118657 304M 0
119689 304M 0
120426 304M 0
120464 304M 0
121051 304M 0
122179 304M 0
122326 304M 0
122330 304M 0
123357 304M 0
124196 304M 0
124209 304M 0
124886 304M 0
124934 304M 0
125585 304M 0
125593 304M 0
125755 304M 0
126598 304M 0
128544 304M 0
129203 304M 0
129552 304M 0
130340 304M 0
130403 304M 0
131962 304M 0
133778 304M 0
134524 304M 0
135432 304M 0
135956 304M 0
137235 304M 0
137428 304M 0
137550 304M 0
141350 304M 0
142199 304M 0
142280 304M 0
143235 304M 0
144198 304M 0
145090 304M 0
146242 304M 0
147362 304M 0
147385 304M 0
149363 304M 0
149707 304M 0
151549 304M 0
151672 304M 0
151844 304M 0
151873 304M 0
157189 304M 0
158252 304M 0
158535 304M 0
160305 304M 0
160560 304M 0
161753 304M 0
162915 304M 0
164157 304M 0
166942 304M 0
167453 304M 0
168486 304M 0
168881 304M 0
169683 304M 0
170490 304M 0
170791 304M 0
171144 304M 0
172324 304M 0
173481 304M 0
177999 304M 0