SELECT 
  cscart_ab__mb_motivation_items.*, 
  cscart_ab__mb_motivation_item_descriptions.name, 
  cscart_ab__mb_motivation_item_descriptions.description, 
  cscart_ab__mb_motivation_item_descriptions.lang_code, 
  vd.description AS vendor_description, 
  vd.status as vendor_status 
FROM 
  cscart_ab__mb_motivation_items 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as destination_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = destination_objects_not_exclude.motivation_item_id 
  AND destination_objects_not_exclude.object_type = 'D' 
  AND cscart_ab__mb_motivation_items.exclude_destinations = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as destination_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = destination_objects_exclude.motivation_item_id 
  AND destination_objects_exclude.object_type = 'D' 
  AND destination_objects_exclude.object_id IN (8) 
  AND cscart_ab__mb_motivation_items.exclude_destinations = "Y" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as category_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = category_objects_not_exclude.motivation_item_id 
  AND category_objects_not_exclude.object_type = 'C' 
  AND cscart_ab__mb_motivation_items.exclude_categories = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as category_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = category_objects_exclude.motivation_item_id 
  AND category_objects_exclude.object_type = 'C' 
  AND category_objects_exclude.object_id IN (43213) 
  AND cscart_ab__mb_motivation_items.exclude_categories = "Y" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as product_objects_not_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = product_objects_not_exclude.motivation_item_id 
  AND product_objects_not_exclude.object_type = 'P' 
  AND cscart_ab__mb_motivation_items.exclude_products = "N" 
  LEFT JOIN cscart_ab__mb_motivation_item_objects as product_objects_exclude ON cscart_ab__mb_motivation_items.motivation_item_id = product_objects_exclude.motivation_item_id 
  AND product_objects_exclude.object_type = 'P' 
  AND product_objects_exclude.object_id IN (143) 
  AND cscart_ab__mb_motivation_items.exclude_products = "Y" 
  LEFT JOIN cscart_ab__mb_vendors_descriptions AS vd ON vd.motivation_item_id = cscart_ab__mb_motivation_items.motivation_item_id 
  AND vd.company_id = 1 
  AND vd.lang_code = 'de' 
  INNER JOIN cscart_ab__mb_motivation_item_descriptions ON cscart_ab__mb_motivation_item_descriptions.motivation_item_id = cscart_ab__mb_motivation_items.motivation_item_id 
  AND cscart_ab__mb_motivation_item_descriptions.lang_code = 'de' 
WHERE 
  1 
  AND cscart_ab__mb_motivation_items.status = 'A' 
  AND (
    cscart_ab__mb_motivation_items.usergroup_ids = '' 
    OR FIND_IN_SET(
      0, cscart_ab__mb_motivation_items.usergroup_ids
    ) 
    OR FIND_IN_SET(
      1, cscart_ab__mb_motivation_items.usergroup_ids
    )
  ) 
  AND (
    (
      destination_objects_not_exclude.object_id IN (0, 8) 
      OR destination_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      destination_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND (
    (
      category_objects_not_exclude.object_id IN (0, 43213) 
      OR category_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      category_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND (
    (
      product_objects_not_exclude.object_id IN (0, 143) 
      OR product_objects_not_exclude.object_id IS NULL
    ) 
    AND (
      product_objects_exclude.motivation_item_id IS NULL
    )
  ) 
  AND cscart_ab__mb_motivation_items.storefront_id = 1 
GROUP BY 
  cscart_ab__mb_motivation_items.motivation_item_id 
ORDER BY 
  cscart_ab__mb_motivation_items.position asc

Query time 0.00089

JSON explain

{
  "query_block": {
    "select_id": 1,
    "cost": 0.04738964,
    "filesort": {
      "sort_key": "cscart_ab__mb_motivation_items.position",
      "temporary_table": {
        "nested_loop": [
          {
            "table": {
              "table_name": "cscart_ab__mb_motivation_items",
              "access_type": "index",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "7",
              "used_key_parts": ["motivation_item_id", "storefront_id"],
              "loops": 1,
              "rows": 4,
              "cost": 0.0115068,
              "filtered": 100,
              "attached_condition": "cscart_ab__mb_motivation_items.storefront_id = 1 and cscart_ab__mb_motivation_items.`status` = 'A' and (cscart_ab__mb_motivation_items.usergroup_ids = '' or find_in_set(0,cscart_ab__mb_motivation_items.usergroup_ids) or find_in_set(1,cscart_ab__mb_motivation_items.usergroup_ids))"
            }
          },
          {
            "table": {
              "table_name": "destination_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(destination_objects_not_exclude.object_id in (0,8) or destination_objects_not_exclude.object_id is null) and trigcond(destination_objects_not_exclude.object_type = 'D' and trigcond(cscart_ab__mb_motivation_items.exclude_destinations = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "destination_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(destination_objects_exclude.motivation_item_id is null) and trigcond(destination_objects_exclude.object_type = 'D' and trigcond(cscart_ab__mb_motivation_items.exclude_destinations = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "cscart_ab__mb_motivation_item_descriptions",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "lang_code"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00439696,
              "filtered": 100,
              "attached_condition": "cscart_ab__mb_motivation_item_descriptions.lang_code = 'de'"
            }
          },
          {
            "table": {
              "table_name": "category_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(category_objects_not_exclude.object_id in (0,43213) or category_objects_not_exclude.object_id is null) and trigcond(category_objects_not_exclude.object_type = 'C' and trigcond(cscart_ab__mb_motivation_items.exclude_categories = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "category_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(category_objects_exclude.motivation_item_id is null) and trigcond(category_objects_exclude.object_type = 'C' and trigcond(cscart_ab__mb_motivation_items.exclude_categories = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "product_objects_not_exclude",
              "access_type": "ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "6",
              "used_key_parts": ["motivation_item_id", "object_type"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00471282,
              "filtered": 100,
              "attached_condition": "trigcond(product_objects_not_exclude.object_id in (0,143) or product_objects_not_exclude.object_id is null) and trigcond(product_objects_not_exclude.object_type = 'P' and trigcond(cscart_ab__mb_motivation_items.exclude_products = 'N'))",
              "using_index": true
            }
          },
          {
            "table": {
              "table_name": "product_objects_exclude",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY", "mid_otype"],
              "key": "mid_otype",
              "key_length": "9",
              "used_key_parts": ["motivation_item_id", "object_type", "object_id"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00431682,
              "filtered": 100,
              "attached_condition": "trigcond(product_objects_exclude.motivation_item_id is null) and trigcond(product_objects_exclude.object_type = 'P' and trigcond(cscart_ab__mb_motivation_items.exclude_products = 'Y'))",
              "using_index": true,
              "not_exists": true
            }
          },
          {
            "table": {
              "table_name": "vd",
              "access_type": "eq_ref",
              "possible_keys": ["PRIMARY"],
              "key": "PRIMARY",
              "key_length": "13",
              "used_key_parts": ["motivation_item_id", "company_id", "lang_code"],
              "ref": [
                "cscart.cscart_ab__mb_motivation_items.motivation_item_id",
                "const",
                "const"
              ],
              "loops": 4,
              "rows": 1,
              "cost": 0.00439696,
              "filtered": 100,
              "attached_condition": "trigcond(vd.lang_code = 'de')"
            }
          }
        ]
      }
    }
  }
}

Result

motivation_item_id storefront_id position expanded_desktop expanded_tablet expanded_mobile vendor_edit status icon_type icon_class icon_color exclude_categories exclude_destinations exclude_products template_path template_settings usergroup_ids name description lang_code vendor_description vendor_status
1 1 100 Y N N Y A icon ut2-icon-outline-local_shipping #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"24";} 0 Versand & Versandkosten <p><img src="https://www.buby.at/images/gls.png?1742980215163" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/dhl.png?1742980235491" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/dpd.png?1742980869615" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/post-austria.png?1742980927034" alt="" width="64" height="46" /></p> <p><img src="https://www.buby.at/images/pickup.png?1742981175015" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/ups.png?1742981228479" alt="" width="64" height="46" /></p> de <p><img src="https://www.buby.at/images/gls.png?1742980215163" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/dhl.png?1742980235491" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/dpd.png?1742980869615" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/post-austria.png?1742980927034" alt="" width="64" height="46" /></p> A
2 1 110 N N N Y A icon ut2-icon-baseline-credit_card #666666 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"24";} 0 Zahlungsmethoden <p><img src="https://www.buby.at/images/klarna.png?1742979173273" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/mastercard.png?1742979249436" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/paypal.png?1742979307210" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/sepa.png?1742979378789" alt="" width="64" height="46" /> </p> <p><img src="https://www.buby.at/images/stripe.png?1742979418083" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/invoice.png?1742979507767" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/cash-on-pickup.png?1742979558619" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/visa-alternate.png?1742979683649" alt="" width="64" height="46" /></p> <p><img src="https://www.buby.at/images/text-nachnahme.png?1742979757349" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/text-ueberweisung.png?1742979789532" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/text-vorkasse.png?1742979823665" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/text-lastschrift.png?1742979893993" alt="" width="64" height="46" /></p> de <p><img src="https://www.buby.at/images/klarna.png?1742979173273" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/mastercard.png?1742979249436" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/paypal.png?1742979307210" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/sepa.png?1742979378789" alt="" width="64" height="46" /> </p> <p><img src="https://www.buby.at/images/stripe.png?1742979418083" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/invoice.png?1742979507767" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/cash-on-pickup.png?1742979558619" alt="" width="64" height="46" /> <img src="https://www.buby.at/images/visa-alternate.png?1742979683649" alt="" width="64" height="46" /> </p> A
3 1 120 N N N Y A icon ut2-icon-outline-new_releases #999999 N N N addons/ab__motivation_block/blocks/components/item_templates/custom_content.tpl a:2:{s:16:"brand_feature_id";s:2:"18";s:19:"tags_items_per_page";s:2:"24";} 0 Ihre Benefits bei uns <ul> <li>— 12 months warranty <span class="cm-tooltip" title="Guarantee for all products in our store is 12 months."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— SMS notification <span class="cm-tooltip" title="You receive SMS messages about each stage of your order."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Return and exchange <span class="cm-tooltip" title="You can return the items purchased within 14 days. The goods must be in normal condition and have all the factory packages."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Different payment methods <span class="cm-tooltip" title="Pay orders in convenient ways: cash to the courier, by bank transfer on the receipt of the bank or by credit card right at the time of the order."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Best price <span class="cm-tooltip" title="We are proud of our prices, hundreds of customers check them every day, which give a choice to our online store!"><i class="ut2-icon-outline-info-circle"></i></span></li> </ul> de <ul> <li>— 12 months warranty <span class="cm-tooltip" title="Guarantee for all products in our store is 12 months."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— SMS notification <span class="cm-tooltip" title="You receive SMS messages about each stage of your order."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Return and exchange <span class="cm-tooltip" title="You can return the items purchased within 14 days. The goods must be in normal condition and have all the factory packages."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Different payment methods <span class="cm-tooltip" title="Pay orders in convenient ways: cash to the courier, by bank transfer on the receipt of the bank or by credit card right at the time of the order."><i class="ut2-icon-outline-info-circle"></i></span></li> <li>— Best price <span class="cm-tooltip" title="We are proud of our prices, hundreds of customers check them every day, which give a choice to our online store!"><i class="ut2-icon-outline-info-circle"></i></span></li> </ul> A