fix empty categories and empty options

This commit is contained in:
Круглов Дмитрий 2019-06-28 17:08:01 +03:00
parent d2d5bef98d
commit db371cfd72

View File

@ -69,6 +69,7 @@ class ModelRetailcrmIcml extends Model
foreach($categories as $category) { foreach($categories as $category) {
$category = $this->model_catalog_category->getCategory($category['category_id']); $category = $this->model_catalog_category->getCategory($category['category_id']);
if (!empty($category)) {
$e = $this->eCategories->appendChild( $e = $this->eCategories->appendChild(
$this->dd->createElement( $this->dd->createElement(
'category', $category['name'] 'category', $category['name']
@ -81,7 +82,7 @@ class ModelRetailcrmIcml extends Model
$e->setAttribute('parentId', $category['parent_id']); $e->setAttribute('parentId', $category['parent_id']);
} }
} }
}
} }
private function addOffers() private function addOffers()
@ -174,6 +175,8 @@ class ModelRetailcrmIcml extends Model
$optionIds = explode(':', $option[0]); $optionIds = explode(':', $option[0]);
if($optionString != '0:0-0') { if($optionString != '0:0-0') {
$optionData = $this->getOptionData($optionIds[1], $option[1]); $optionData = $this->getOptionData($optionIds[1], $option[1]);
if (!empty($optionData)) {
$options[$optionIds[0]] = array( $options[$optionIds[0]] = array(
'name' => $optionData['optionName'], 'name' => $optionData['optionName'],
'value' => $optionData['optionValue'], 'value' => $optionData['optionValue'],
@ -181,6 +184,7 @@ class ModelRetailcrmIcml extends Model
); );
} }
} }
}
ksort($options); ksort($options);
$offerId = array(); $offerId = array();
foreach($options as $optionKey => $optionData) { foreach($options as $optionKey => $optionData) {
@ -348,9 +352,14 @@ class ModelRetailcrmIcml extends Model
$optionValue = $this->model_catalog_option->getOptionValue($optionValueId); $optionValue = $this->model_catalog_option->getOptionValue($optionValueId);
$this->optionValues[$optionValueId] = $optionValue; $this->optionValues[$optionValueId] = $optionValue;
} }
if (!empty($option['name']) && !empty($optionValue['name'])) {
return array( return array(
'optionName' => $option['name'], 'optionName' => $option['name'],
'optionValue' => $optionValue['name'] 'optionValue' => $optionValue['name']
); );
} else {
return null;
}
} }
} }