ALTER TABLE Job ADD scope varchar(45) NULL after id;

ALTER VIEW `vProductSortingView` AS
SELECT
  `Product`.`id`                                                 AS `product`,
  `Product`.`productVariantId`                                   AS `variant`,
  `ProductSku`.`shopId`                                          AS `shop`,
  `Tag`.`id`                                                     AS `tag`,
  min(`ProductSku`.`price`)                                      AS `price`,
  `Product`.`sortingPriorityId`                                  AS `productPriority`,
  `Tag`.`sortingPriorityId`                                      AS `tagPriority`,
  `Product`.`productBrandId`                                     AS `brand`,
  `ProductSku`.`productSizeId`                                   AS `size`,
  (CASE WHEN isnull(`ProductHasProductColorGroup`.`productColorGroupId`)
    THEN 1
   ELSE `ProductHasProductColorGroup`.`productColorGroupId` END) AS `color`,
  `ProductHasProductCategory`.`productCategoryId`                AS `category`,
  `ProductCategory`.`lft`                                        AS `lft`,
  max(`ProductSku`.`stockQty`)                                   AS `maxQty`,
  `Product`.`creationDate`                                       AS `creation`
FROM ((((((((`Product`
  JOIN `Tag`) JOIN `ProductStatus`) JOIN `ProductSku`) JOIN `ProductHasTag`) JOIN
  `ProductSize`) JOIN `ProductCategory`) JOIN `ProductHasProductCategory`) LEFT JOIN `ProductHasProductColorGroup`
    ON (((`Product`.`id` = `ProductHasProductColorGroup`.`productId`) AND
         (`Product`.`productVariantId` = `ProductHasProductColorGroup`.`productVariantId`))))
WHERE (
  (`ProductHasTag`.`productId` = `Product`.`id`) AND (`ProductHasTag`.`productVariantId` = `Product`.`productVariantId`)
  AND (`Product`.`productStatusId` = `ProductStatus`.`id`) AND (`ProductStatus`.`isVisible` = 1) AND
  (`ProductHasTag`.`tagId` = `Tag`.`id`) AND (`Product`.`id` = `ProductSku`.`productId`) AND (`ProductSku`.`price` > 0)
  AND (`Product`.`productVariantId` = `ProductSku`.`productVariantId`) AND
  (`ProductSize`.`id` = `ProductSku`.`productSizeId`) AND
  (`ProductHasProductCategory`.`productId` = `Product`.`id`) AND
  (`ProductHasProductCategory`.`productVariantId` = `Product`.`productVariantId`) AND
  (`ProductCategory`.`id` = `ProductHasProductCategory`.`productCategoryId`) AND (`ProductCategory`.`id` <> 1))
GROUP BY `Product`.`id`, `Product`.`productVariantId`, `ProductHasProductCategory`.`productCategoryId`,
  `ProductSku`.`price`, `Tag`.`id`
HAVING ((`maxQty` > 0) AND (`ProductSku`.`price` > 0))
ORDER BY `Tag`.`sortingPriorityId`, `Product`.`sortingPriorityId`;

ALTER TABLE `ProductStatus`
  ADD INDEX `isVisible` (`isVisible`);