예제 #1
0
 /**
  * Check attributes of products and categories.
  *
  * @param array $incomingFieldArray Incoming field array
  * @param bool|int $handleAttributes Whether to handle attributes
  *
  * @return mixed
  */
 protected function preProcessAttributes(array $incomingFieldArray, $handleAttributes)
 {
     if ($handleAttributes) {
         // get all parent categories, excluding this
         $this->belib->getParentCategoriesFromList($this->catList);
         $correlationTypes = array();
         // get all correlation types from flexform thats was created by dynaflex!
         if (is_array($incomingFieldArray) && isset($incomingFieldArray['attributes']) && is_array($incomingFieldArray['attributes']) && isset($incomingFieldArray['attributes']['data']) && is_array($incomingFieldArray['attributes']['data']) && isset($incomingFieldArray['attributes']['data']['sDEF']) && is_array($incomingFieldArray['attributes']['data']['sDEF']) && isset($incomingFieldArray['attributes']['data']['sDEF']['lDEF']) && is_array($incomingFieldArray['attributes']['data']['sDEF']['lDEF'])) {
             $correlationTypes = $incomingFieldArray['attributes']['data']['sDEF']['lDEF'];
         }
         $usedAttributes = array();
         foreach ($correlationTypes as $key => $data) {
             $keyData = array();
             // @todo this cant work, we are checking on a new created empty array
             if ($keyData[0] == 'ct') {
                 // get the attributes from the categories of this product
                 $localAttributes = explode(',', $data['vDEF']);
                 if (is_array($localAttributes)) {
                     $validAttributes = array();
                     foreach ($localAttributes as $localAttribute) {
                         if ($localAttribute == '') {
                             continue;
                         }
                         $attributeUid = $this->belib->getUidFromKey($localAttribute, $keyData);
                         if (!$this->belib->checkArray($attributeUid, $usedAttributes, 'uid_foreign')) {
                             $validAttributes[] = $localAttribute;
                             $usedAttributes[] = array('uid_foreign' => $attributeUid);
                         }
                     }
                     $incomingFieldArray['attributes']['data']['sDEF']['lDEF'][$key]['vDEF'] = implode(',', $validAttributes);
                 }
             }
         }
     }
     return $incomingFieldArray;
 }