owebia / magento2-module-advanced-shipping

Other
90 stars 28 forks source link

Configurable products attribute #32

Closed gewaechshaus closed 6 years ago

gewaechshaus commented 6 years ago

Hey,

it's more a question than an issue. I got a configurable product with 4 simple product childs. Each of it's child got a different attribute called "shippingsize". Now I want to create a rule, but only the parent products attribute "shippingsize" is working, or in conclusion overwriting the childs attribute value. How to access the childs attributes? Are they stored in $item->product object?

addMethod('dpag_int_warensendung_e', [
   'title' => "Economy trackable",
   'enabled'    => count(
                    array_filter($request->all_items, function ($item) {
                        return $item->product->getAttributeText('shippingsize') == 'Plattenware';
                    })
                ) > 0 
               && count(
                    array_filter($request->all_items, function ($item) {
                        return $item->product->getAttributeText('shippingsize') != 'Plattenware';
                    })
                ) == 0 
        && in_array($request->dest_country_id, ['AT','BA','BE','BG','CS','CZ','DK','ES','EE','FI','FR','GB','GR','HR','HU','IR','IT','LT','LU','LV','MC','MT','NL','PL','PT','RO','SE','SK','SI','UA'])
        && $request->package_weight < 0.500 
        && $quote->grand_total < 100,
 'price'      => 6.50
 ]);

Many thanks Jan

owebia commented 6 years ago

Hi Jan,

Have you tried to use the debug functionality to see if the value is present on the item object ?

Best Regards,

gewaechshaus commented 6 years ago

Hi @owebia - not yet, thanks for the hint! Till later...

owebia commented 6 years ago

Supposed to be fixed