/** * Importing the attribute sets from magento * * @return void|CatelogConnector */ public function importProductAttributeSets() { $attributeSets = $this->getProductAttributeSetList(); Log::logging(0, get_class($this), 'getting AttributeSets from magento', self::LOG_TYPE, '', __FUNCTION__); echo 'getting AttributeSets from magento' . "\n"; if (count($attributeSets) === 0) { return; } try { $transStarted = false; try { Dao::beginTransaction(); } catch (Exception $e) { $transStarted = true; } foreach ($attributeSets as $attributeSet) { $mageId = trim($attributeSet->set_id); $name = trim($attributeSet->name); $description = isset($category->description) ? trim($category->description) : $name; Log::logging(0, get_class($this), 'getting AttributeSet(mageId="' . $mageId . '")', self::LOG_TYPE, '', __FUNCTION__); $productAttributeSet = ProductAttributeSet::getByMageId($mageId); if (!$productAttributeSet instanceof ProductAttributeSet) { Log::logging(0, get_class($this), 'found new AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '"' . ')', self::LOG_TYPE, '', __FUNCTION__); echo 'found new AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '"' . ')' . "\n"; $productAttributeSet = ProductAttributeSet::create($name, $description, true, $mageId); } else { Log::logging(0, get_class($this), 'found existing AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '", ID=' . $productAttributeSet->getId() . ')', self::LOG_TYPE, '', __FUNCTION__); echo 'found existing AttributeSet from magento(mageId=' . $mageId . ', name="' . $name . '", ID=' . $productAttributeSet->getId() . ')' . "\n"; $productAttributeSet->setName($name)->setDescription($description); } $productAttributeSet->setActive(true)->save(); } if ($transStarted === false) { Dao::commitTransaction(); } } catch (Exception $e) { Dao::rollbackTransaction(); throw $e; } return $this; }