Jump to content

combinations and attributes


Recommended Posts

hello.
I have to configure a product's price based on num pages and color pages, a  numeric and a string that may change.
I must use combinations?
How?
The problem is that the num of pages can be any quantity, like the colors pages, then if i use the combination generator i have a lot , if not impossible number of possible products.

My workaround is to create an attribute on the fly with the values and add it to the combination.
may be is correct or there are better solutions?

I use the attributes at the end only for changes the price of the product in base of a calculation on the pages.

in pratice i do that all for do this:

$newattr = new AttributeCore();
 $newattr->name = "Pagine col:[".$str."]";
                $newattr->id_attribute_group = 4;
                $newattr->prezzo = 110;//price to change
                $newattr->position = 22;
                $newattr->save();
                $combinationAttributes[] = $newattr->id;
if(!$p = $product->productAttributeExists($combinationAttributes))
                {

                    $price = $obj->total;
                    $weight = 1;
                    $ecotax = 0;
                    $unit_price_impact = 1;
                    $quantity = 1;
                    $reference = "";
                    $supplier_reference = "";
                    $ean13 = "";
                    $default = false;


                    $idProductAttribute = $product->addProductAttribute((float)$price, (float)$weight, $unit_price_impact, (float)$ecotax, (int)$quantity, "", strval($reference), strval($supplier_reference), strval($ean13), $default, NULL, NULL);

                    $product->addAttributeCombinaison($idProductAttribute, $combinationAttributes);
                    
is for that that i generate the attribute on the fly  is always missing and i can generate a new combination with a new price.

 then  sending the idcombination to the cart i have the new price, but is possible to change the price of a product before add it to the cart without combination?
thanks.
Link to comment
Share on other sites

  • 1 month later...
  • 10 months later...
×
×
  • Create New...