[+] BO : now you can choose type of attribute group (select , color, radio)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8691 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
vAugagneur
2011-09-21 14:29:32 +00:00
parent 5bc5979e2d
commit 8b6ec916e0
15 changed files with 204 additions and 146 deletions
+16 -4
View File
@@ -34,7 +34,6 @@ class AttributeCore extends ObjectModel
public $name;
public $color;
public $position;
public $default;
protected $fieldsRequired = array('id_attribute_group');
@@ -53,7 +52,14 @@ class AttributeCore extends ObjectModel
'id_attribute_group' => array('xlink_resource'=> 'product_options'),
),
);
public function __construct()
{
$this->image_dir = _PS_COL_IMG_DIR_;
parent::__construct();
}
public function getFields()
{
$this->validateFields();
@@ -182,16 +188,22 @@ class AttributeCore extends ObjectModel
return false;
}
/**
* Return true if attribute is color type
*
* @acces public
* @return bool
*/
public function isColorAttribute()
{
if (!Db::getInstance()->getRow('
SELECT `is_color_group` FROM `'._DB_PREFIX_.'attribute_group` WHERE `id_attribute_group` = (
SELECT `group_type` FROM `'._DB_PREFIX_.'attribute_group` WHERE `id_attribute_group` = (
SELECT `id_attribute_group` FROM `'._DB_PREFIX_.'attribute` WHERE `id_attribute` = '.(int)$this->id.')
AND is_color_group = 1'))
AND group_type = \'color\''))
return false;
return Db::getInstance()->NumRows();
}
/**
* Get minimal quantity for product with attributes quantity
*
+2
View File
@@ -31,6 +31,7 @@ class AttributeGroupCore extends ObjectModel
public $name;
public $is_color_group;
public $position;
public $group_type;
/** @var string Public Name */
public $public_name;
@@ -62,6 +63,7 @@ class AttributeGroupCore extends ObjectModel
$this->validateFields();
$fields['is_color_group'] = (int)($this->is_color_group);
$fields['group_type'] = pSQL($this->group_type);
$fields['position'] = (int)($this->position);
return $fields;
+2 -6
View File
@@ -54,9 +54,6 @@ class ProductCore extends ObjectModel
/** @var integer default Category id */
public $id_category_default;
/** @var integer default Attribute id if color picker is enabled */
public $id_color_default;
/** @var string Manufacturer name */
public $manufacturer_name;
@@ -225,7 +222,6 @@ class ProductCore extends ObjectModel
'id_manufacturer' => 'isUnsignedId',
'id_supplier' => 'isUnsignedId',
'id_category_default' => 'isUnsignedId',
'id_color_default' => 'isUnsignedInt', /* unsigned integer because its value could be 0 if the feature is disabled */
'minimal_quantity' => 'isUnsignedInt',
'price' => 'isPrice',
'additional_shipping_cost' => 'isPrice',
@@ -353,7 +349,6 @@ class ProductCore extends ObjectModel
$fields['id_manufacturer'] = (int)($this->id_manufacturer);
$fields['id_supplier'] = (int)($this->id_supplier);
$fields['id_category_default'] = (int)($this->id_category_default);
$fields['id_color_default'] = (int)($this->id_color_default);
$fields['quantity'] = (int)($this->quantity);
$fields['minimal_quantity'] = (int)($this->minimal_quantity);
$fields['price'] = (float)($this->price);
@@ -2317,7 +2312,8 @@ class ProductCore extends ObjectModel
if (!Combination::isFeatureActive())
return array();
$sql = 'SELECT ag.`id_attribute_group`, ag.`is_color_group`, agl.`name` AS group_name, agl.`public_name` AS public_group_name, a.`id_attribute`, al.`name` AS attribute_name,
a.`color` AS attribute_color, pa.`id_product_attribute`, stock.quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`, pa.`minimal_quantity`, pa.`available_date`
a.`color` AS attribute_color, pa.`id_product_attribute`, stock.quantity, pa.`price`, pa.`ecotax`, pa.`weight`, pa.`default_on`, pa.`reference`, pa.`unit_price_impact`,
pa.`minimal_quantity`, pa.`available_date`, ag.`group_type`
FROM `'._DB_PREFIX_.'product_attribute` pa
'.Product::sqlStock('pa', 'pa').'
LEFT JOIN `'._DB_PREFIX_.'product_attribute_combination` pac ON pac.`id_product_attribute` = pa.`id_product_attribute`