throw new CustomValidationException(sprintf('Field position is missing in manualSorting array'
));
} if (!
$connection->
fetchOne('SELECT 1 FROM s_articles_categories_ro WHERE categoryID = ? AND articleID = ?',
[ $category->
getId(),
$sorting['product_id'
],
])) { throw new CustomValidationException(sprintf('Product with id %d is not assigned to the category',
$sorting['product_id'
]));
} $sortingObj =
new ManualSorting();
$sortingObj->
setCategory($category);
$product =
$this->
getManager()->
find(Product::
class,
$sorting['product_id'
]);
if (!
$product instanceof Product
) { throw new ModelNotFoundException(Product::
class,
$sorting['product_id'
]);
} $sortingObj->
setProduct($product);
$sortingObj->
setPosition((int) $sorting['position'
]);
$collection[] =
$sortingObj;
}