public function save()
{
$manufacturer = Manufacturer::model()->findByPk($this->id);
if (is_null($manufacturer)) {
// is insert
$manufacturer = new Manufacturer();
}
$manufacturer->name = $this->name;
$manufacturer->image = $this->image;
$manufacturer->sort_order = $this->sortOrder;
$manufacturer->save();
// SEO Keyword
$manufacturer->updateSEOKeyword($this->seoKeyword);
// Stores
$manufacturer->clearAllStoresRelations();
if (isset($this->stores) && count($this->stores)) {
foreach ($this->stores as $storeId) {
$manufacturer->addToStore($storeId);
}
}
}