/**
  * Unserialize the sorted_products field of category if it is a string value.
  *
  * @param \Magento\Catalog\Model\Category $category Category
  *
  * @return array
  */
 private function unserializeProductPositions(\Magento\Catalog\Model\Category $category)
 {
     $productPositions = $category->getSortedProducts() ? $category->getSortedProducts() : [];
     if (is_string($productPositions)) {
         try {
             $productPositions = $this->jsonHelper->jsonDecode($productPositions);
         } catch (\Exception $e) {
             $productPositions = [];
         }
     }
     $category->setSortedProducts($productPositions);
     return $this;
 }