Jump to content

Edit History

EvaF

EvaF

no problem, all three tables(ps_cart_rule_product_rule...) are very simple (I am working with Prestashop 1.7.5.1, but I do not expect any changes compared to PS 1.6 in this area)
steps:
1) set cart_rule->product_restriction

$coupon->cart_rule->product_restriction = 1;     // Do not forget to activate product_restriction!!! ( according your $coupon structure)

2) insert into ps_cart_rule_product_rule_group table, got  id_product_rule_group of inserted row ( at the picture bellow id_product_rule_group = 14)

$quantity = 1;  // set yourself
$id_cart_rule = $coupon->cart_rule->id;  // set yourself according your code

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_group` (`id_cart_rule`, `quantity`)
				VALUES (' . (int) $id_cart_rule . ', ' . (int) $quantity . ')');
                $id_product_rule_group = Db::getInstance()->Insert_ID();

PS2.png.aed532543e83b453b32a5002bbc8af01.png

3)  insert into ps_cart_rule_product_rule table, got  id_product_rule of inserted row ( at the picture bellow id_product_rule = 13), you can set type "manufacturers" by hand

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule` (`id_product_rule_group`, `type`)
						VALUES (' . (int) $id_product_rule_group . ', "manufacturers")');
                        $id_product_rule = Db::getInstance()->Insert_ID();

PS1.png.92a140286b77ee9fe13fc2022777db48.png

4) insert into ps_cart_rule_product_value table the id(s) of manufacturers

 Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) SELECT ' .
                            $id_product_rule . ',id_manufacturer FROM `' . _DB_PREFIX_ . 'manufacturer` where name in ("LG","DMECG")');

PS3.png.0a64416693f2a70365406f6d56ff413a.png

PS4.png.7dee878c1544bb7862ca1d0f8f07cc0f.png

EvaF

EvaF

no problem, all three tables(ps_cart_rule_product_rule...) are very simple (I am working with Prestashop 1.7.5.1, but I do not expect any changes compared to PS 1.6 in this area)
steps:
1) set cart_rule->product_restriction

$coupon->cart_rule->product_restriction = 1;     // Do not forget to activate product_restriction!!! ( according your $coupon structure)

2) insert into ps_cart_rule_product_rule_group table, got  id_product_rule_group of inserted row ( at the picture bellow id_product_rule_group = 14)

$quantity = 1;  // set yourself
$id_cart_rule = $coupon->cart_rule->id;  // set yourself according your code

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_group` (`id_cart_rule`, `quantity`)
				VALUES (' . (int) $id_cart_rule . ', ' . (int) $quantity . ')');
                $id_product_rule_group = Db::getInstance()->Insert_ID();

PS2.png.aed532543e83b453b32a5002bbc8af01.png

3)  insert into ps_cart_rule_product_rule table, got  id_product_rule of inserted row ( at the picture bellow id_product_rule = 13), you can set type "manufactures" by hand

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule` (`id_product_rule_group`, `type`)
						VALUES (' . (int) $id_product_rule_group . ', "manufactures")');
                        $id_product_rule = Db::getInstance()->Insert_ID();

PS1.png.92a140286b77ee9fe13fc2022777db48.png

4) insert into ps_cart_rule_product_value table the id(s) of manufacturers

 Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) SELECT ' .
                            $id_product_rule . ',id_manufacturer FROM `' . _DB_PREFIX_ . 'manufacturer` where name in ("LG","DMECG")');

PS3.png.0a64416693f2a70365406f6d56ff413a.png

PS4.png.7dee878c1544bb7862ca1d0f8f07cc0f.png

EvaF

EvaF

no problem, all three tables(ps_cart_rule_product_rule...) are very simple (I am working with Prestashop 1.7.5.1, but I do not expect any changes compared to PS 1.6 in this area)
steps:

1) insert into ps_cart_rule_product_rule_group table, got  id_product_rule_group of inserted row ( at the picture bellow id_product_rule_group = 14)

$quantity = 1;  // set yourself
$id_cart_rule = $coupon->cart_rule->id;  // set yourself according your code
Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_group` (`id_cart_rule`, `quantity`)
				VALUES (' . (int) $id_cart_rule . ', ' . (int) $quantity . ')');
                $id_product_rule_group = Db::getInstance()->Insert_ID();

PS2.png.aed532543e83b453b32a5002bbc8af01.png

2)  insert into ps_cart_rule_product_rule table, got  id_product_rule of inserted row ( at the picture bellow id_product_rule = 13), you can set type "manufactures" by hand

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule` (`id_product_rule_group`, `type`)
						VALUES (' . (int) $id_product_rule_group . ', "manufactures")');
                        $id_product_rule = Db::getInstance()->Insert_ID();

PS1.png.92a140286b77ee9fe13fc2022777db48.png

3) insert into ps_cart_rule_product_value table the id(s) of manufacturers

 Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) SELECT ' .
                            $id_product_rule . ',id_manufacturer FROM `' . _DB_PREFIX_ . 'manufacturer` where name in ("LG","DMECG")');

PS3.png.0a64416693f2a70365406f6d56ff413a.png

PS4.png.7dee878c1544bb7862ca1d0f8f07cc0f.png

EvaF

EvaF

no problem, all three tables(ps_cart_rule_product_rule...) are very simple (I am working with Prestashop 1.7.5.1, but I do not expect any changes compared to PS 1.6 in this area)
steps:

1) insert into ps_cart_rule_product_rule_group table, got  id_product_rule_group of inserted row ( at the picture bellow id_product_rule_group = 14)

 Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_group` (`id_cart_rule`, `quantity`)
				VALUES (' . (int) $currentObject->id . ', ' . (int) Tools::getValue('product_rule_group_' . $ruleGroupId . '_quantity') . ')');
                $id_product_rule_group = Db::getInstance()->Insert_ID();

PS2.png.aed532543e83b453b32a5002bbc8af01.png

2)  insert into ps_cart_rule_product_rule table, got  id_product_rule of inserted row ( at the picture bellow id_product_rule = 13), you can set type "manufactures" by hand

Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule` (`id_product_rule_group`, `type`)
						VALUES (' . (int) $id_product_rule_group . ', "manufactures")');
                        $id_product_rule = Db::getInstance()->Insert_ID();

PS1.png.92a140286b77ee9fe13fc2022777db48.png

3) insert into ps_cart_rule_product_value table the id(s) of manufacturers

 Db::getInstance()->execute('INSERT INTO `' . _DB_PREFIX_ . 'cart_rule_product_rule_value` (`id_product_rule`, `id_item`) SELECT ' .
                            $id_product_rule . ',id_manufacturer FROM `' . _DB_PREFIX_ . 'manufacturer` where name in ("LG","DMECG")');

PS3.png.0a64416693f2a70365406f6d56ff413a.png

PS4.png.7dee878c1544bb7862ca1d0f8f07cc0f.png

×
×
  • Create New...