SELECT DISTINCT
    `product`.`relative` AS `relative`,
    `product`.`users_sid` AS `users_sid`,
    `product`.`global_branch_office_id` AS `global_branch_office_id`,
    `product`.`product_kind` AS `product_kind`,
    `product`.`fullname` AS `fullname`,
    `product`.`description` AS `description`,
    `product`.`code` AS `code`,
    `product`.`category_id` AS `category_id`,
    `product`.`subcategory_id` AS `subcategory_id`,
    `product`.`brand_id` AS `brand_id`,
    `product`.`images` AS `images`,
    `product`.`barcode` AS `barcode`,
    `product`.`enabled` AS `enabled`,
    `product`.`status` AS `status`,
    `product`.`created_at` AS `created_at`,
    `product`.`updated_at` AS `updated_at`,
    `price`.`price` AS `price`,
    `price`.`currency_id` AS `currency_id`,
    `currency`.`code` AS `currency`,
    `core_sivir`.`category`.`label` AS `category`,
    `stock`.`quantity` AS `quantity`,
    `stock`.`measurement_id` AS `measurement_id`,
    `core_sivir`.`measurement`.`label` AS `measurement`
FROM
    (
        (
            (
                (
                    (
                        `core_sivir`.`sivir_products` `product`
                    JOIN `core_sivir`.`sivir_products_price` `price`
                    )
                JOIN `core_sivir`.`core_sivir_currency` `currency`
                )
            JOIN `core_sivir`.`sivir_catalog_category` `category`
            )
        JOIN `core_sivir`.`sivir_products_stock` `stock`
        )
    JOIN `core_sivir`.`sivir_catalog_measurement` `measurement`
    )
WHERE
    (
        (
            `product`.`product_kind` != 'IAF'
        ) AND(
            `product`.`relative` = `price`.`product_id`
        ) AND(
            `product`.`relative` = `stock`.`product_id`
        ) AND(
            `price`.`currency_id` = `currency`.`codigoClasificador`
        ) AND(
            `product`.`category_id` = `core_sivir`.`category`.`value`
        ) AND(
            `product`.`global_branch_office_id` = `core_sivir`.`category`.`global_branch_office_id`
        ) AND(
            `stock`.`measurement_id` = `core_sivir`.`measurement`.`value`
        ) AND(
            `product`.`global_branch_office_id` = `core_sivir`.`measurement`.`global_branch_office_id`
        )
    )
