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 
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') 
WHERE 
  cscart_products_categories.product_id IN (
    155, 156, 157, 158, 159, 160, 161, 162, 
    163, 164, 165, 166, 167, 168, 169, 170, 
    171, 172, 173, 174, 175, 176, 177, 178, 
    179, 180, 181, 182, 183, 184, 185, 186, 
    187, 188, 189, 190, 191, 192, 193, 194, 
    195, 196, 197, 198, 199, 200, 201, 202, 
    203, 204, 205, 206, 207, 208, 209, 210, 
    211, 212, 213, 214, 215, 216, 217, 218, 
    219, 220, 221, 222, 223, 224, 225, 226, 
    227, 228, 229, 230, 231, 232, 233, 234, 
    235, 236, 237, 238, 239, 240, 241, 242, 
    243, 244, 245, 246, 247, 248, 249, 250
  ) 
GROUP BY 
  cscart_products_categories.product_id

Query time 0.00253

JSON explain

{
  "query_block": {
    "select_id": 1,
    "table": {
      "table_name": "cscart_products_categories",
      "access_type": "range",
      "possible_keys": ["PRIMARY", "pt"],
      "key": "pt",
      "key_length": "3",
      "used_key_parts": ["product_id"],
      "rows": 96,
      "filtered": 100,
      "index_condition": "cscart_products_categories.product_id in (155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,249,250)"
    },
    "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": ["bacpvdev_db.cscart_products_categories.category_id"],
      "rows": 1,
      "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')"
    }
  }
}

Result

product_id category_ids
155 6M
156 27M
157 20M
158 27M
159 27M
160 27M
161 21M
162 21M
163 27M
164 27M
165 27M
166 21M
167 27M
168 21M
169 27M
170 21M
171 27M
172 27M
173 27M
174 27M
175 27M
176 27M
177 27M
178 27M
179 27M
180 27M
181 27M
182 21M
183 27M
184 27M
185 27M
186 27M
187 27M
188 27M
189 27M
190 27M
191 27M
192 27M
193 27M
194 27M
195 27M
196 27M
197 20M
198 28M
199 28M
200 28M
201 19M
202 19M
203 19M
204 19M
205 19M
206 19M
207 19M
208 19M
209 19M
210 19M
211 27M
212 22M
213 22M
214 22M
215 22M
216 22M
217 22M
218 19M
219 27M
220 29M
221 27M
222 27M
223 27M
224 20M
225 23M
226 23M
227 23M
228 23M
229 23M
230 20M
231 27M
232 27M
233 27M
234 22M
235 27M
236 8M
237 8M
238 8M
239 27M
240 27M
241 20M
242 27M
243 27M
244 27M
245 27M
246 27M
247 24M
248 27M
249 27M
250 27M