public function hasOneMainCategory()
{
if ($this->getCategories()->count() == 0) {
return false;
}
$has = false;
foreach ($this->getProductCategories() as $productCategory) {
if ($productCategory->getMain()) {
if ($has) {
$has = false;
break;
}
$has = true;
}
}
return $has;
}