$this->useFields(array('company_categ_id', 'ad_mobile_image'));
//Narrow down the valid options for some field validators
- $companyCategs = CompanyCategoryTable::getInstance()->getCompanyCategoriesByCompanyIdQuery($this->getOption('company_user_id'));
+ $companyCategs = CompanyCategoryTable::getInstance()->getCompanyCategoriesByCompanyIdQuerySkipMain($this->getOption('company_user_id'));
//The default value is not good enough for us. We need narrow down the results.
$this->widgetSchema['company_categ_id'] = new sfWidgetFormDoctrineChoice(array('model' => $this->getModelName(),
{
if ($currentCategory != null)
{
- return $this->createQuery('cc')->where('cc.level != ?', '0')
- ->andWhere('cc.company_id = ?', $companyId)
+ return $this->createQuery('cc')->where('cc.level = ?', '0')
+ ->orWhere('cc.company_id = ?', $companyId)
->andWhere('cc.lft > ? or cc.lft < ?', array($currentRgt, $currentLft))
->orderBy('cc.lft');
}
else
{
return $this->createQuery('cc')->where('cc.company_id = ?', $companyId)
- ->andWhere('cc.level != ?', '0')
+ ->orWhere('cc.level = ?', '0')
->orderBy('cc.lft');
}
}
+
+
+ /**
+ * Returns company categories by company id skipping the main category called Producto.
+ *
+ * @return related company categories to a company as Doctrine Query
+ */
+ public function getCompanyCategoriesByCompanyIdQuerySkipMain($companyId)
+ {
+ return $this->createQuery('cc')->where('cc.company_id = ?', $companyId)
+ ->andWhere('cc.level != ?', '0')
+ ->orderBy('cc.lft');
+ }
}