/** * @param $code * @param null $title * @param string $locale * * @return Model\CustomerFamily */ public static function getCustomerFamilyByCode($code, $title = null, $locale = "fr_FR") { if ($title == null) { $title = $code; } /** @var CustomerFamilyModel $customerFamily */ if (null == ($customerFamily = CustomerFamilyQuery::create()->useCustomerFamilyI18nQuery()->filterByLocale($locale)->endUse()->filterByCode($code)->findOne())) { //Be sure that you don't create it twice /** @var CustomerFamilyModel $customerF */ if (null != ($customerF = CustomerFamilyQuery::create()->findOneByCode($code))) { $customerF->setLocale($locale)->setTitle($title)->save(); } else { $customerFamily = new CustomerFamilyModel(); $customerFamily->setCode($code)->setLocale($locale)->setTitle($title)->save(); } } return $customerFamily; }
/** * @param string $code */ public function setCode($code) { $this->customerFamily->setCode($code); }