Ejemplo n.º 1
0
 private function addCategories()
 {
     $categories_names = [];
     foreach ($this->products_data as $product) {
         if ($product['category']) {
             $categories_names[] = $product['category'];
         }
     }
     $categories_names = array_unique($categories_names);
     $category_array = OrganizationsCategories::getKeyNameArray($categories_names, $this->organization);
     return $category_array;
 }
Ejemplo n.º 2
0
 public static function getWithCategory($org_id, $status = self::ACTIVE)
 {
     $sql = 'SELECT op.id, op.name, op.price, op.articul, oc.name AS category_name, ' . ' op.product_description, op.min_count, op.measure, op.category_id, ' . ' op.product_rate as product_rate, ' . ' oc.bonus_rate as category_rate ' . ' FROM ' . self::tableName() . ' op ' . ' LEFT JOIN ' . OrganizationsCategories::tableName() . ' oc ' . ' ON oc.id = op.category_id ' . ' WHERE op.organization_id = :org_id ' . ' AND op.is_active = :status';
     return self::findBySql($sql, [':org_id' => $org_id, ':status' => $status])->asArray()->all();
 }