Ejemplo n.º 1
0
 public static function loadEav()
 {
     if (!self::$eavQueue) {
         return false;
     }
     ClassLoader::import('application.model.eav.EavObject');
     ClassLoader::import('application.model.eav.EavSpecificationManager');
     // create array of EavObject gateway objects for all queued records
     $eavObjects = array();
     foreach (self::$eavQueue as $class => &$records) {
         $field = EavObject::getClassField($class);
         foreach ($records as $id => $record) {
             $eavObjects[] = array('ID' => $record['eavObjectID'], $field => $id);
         }
     }
     // fetch EAV values
     if ($eavObjects) {
         EavSpecificationManager::loadSpecificationForRecordSetArray($eavObjects, true);
         // assign attribute values to the respective records
         foreach ($eavObjects as $entry) {
             unset($entry['ID']);
             foreach ($entry as $field => $refId) {
                 if ($refId) {
                     $class = ucfirst(substr($field, 0, -2));
                     if (isset($entry['attributes'])) {
                         self::$eavQueue[$class][$refId]['attributes'] = $entry['attributes'];
                         foreach ($entry['attributes'] as $attr) {
                             self::$eavQueue[$class][$refId]['byHandle'][$attr['EavField']['handle']] = $attr;
                         }
                     }
                     break;
                 }
             }
         }
     }
     self::$eavQueue = array();
 }