Ejemplo n.º 1
0
 public function getAttributeValue($p_id, $attr_id, $attr_type, $dafault_value)
 {
     switch ($attr_type) {
         case 'text':
         case 'textarea':
             $count = ProductAttributesValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->count();
             if ($count > 0) {
                 return ProductAttributesValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->pluck('attribute_value');
             }
             break;
         case 'select':
         case 'option':
             // radio button
         // radio button
         case 'multiselectlist':
         case 'check':
             // checkbox
             $count = ProductAttributesOptionValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->count();
             if ($count > 0) {
                 $rtn_arr = array();
                 $t_arr = ProductAttributesOptionValues::where('attribute_id', '=', $attr_id)->where('product_id', '=', $p_id)->get(array('attribute_options_id'))->toArray();
                 foreach ($t_arr as $arr) {
                     $rtn_arr[] = $arr['attribute_options_id'];
                 }
                 return $rtn_arr;
             }
             break;
     }
     return $dafault_value;
 }
Ejemplo n.º 2
0
 public function isOptionsAlreadyUsed($attribute_id)
 {
     $attribute_used = false;
     // check attribute options used in items
     $attr_option_count = ProductAttributesOptionValues::whereRaw('attribute_id = ?', array($attribute_id))->count();
     if ($attr_option_count > 0) {
         $attribute_used = true;
     } else {
         // check attributes without options like textbox/textarea used in items
         $attr_values_count = ProductAttributesValues::whereRaw('attribute_id = ?', array($attribute_id))->count();
         if ($attr_values_count > 0) {
             $attribute_used = true;
         }
     }
     return $attribute_used;
 }