Example #1
0
 public static function collectionIntegrityCheck($collection)
 {
     $return = new \stdClass();
     $return->status = 'ok';
     $return->errors = array();
     // Check if there are other collections that have the same alias
     try {
         $conflictingCollectionId = \Components\Storefront\Models\Collection::findActiveCollectionByAlias($collection->getAlias());
         if ($conflictingCollectionId && $conflictingCollectionId != $collection->getId()) {
             $return->status = 'error';
             $return->errors[] = 'There is already another collection published with the same alias. Alias must be unique.';
         }
     } catch (\Exception $e) {
         // No conflicting product found (hence, the Exception), good to go.
         return $return;
     }
     return $return;
 }