ProductBulkLoader::processVariation PHP Method

processVariation() public method

public processVariation ( &$obj, $val, $record )
    public function processVariation(&$obj, $val, $record)
    {
        if (isset($record['->variationRow'])) {
            return;
        }
        //don't use this technique for variation rows
        $parts = explode(":", $val);
        if (count($parts) == 2) {
            $attributetype = trim($parts[0]);
            $attributevalues = explode(",", $parts[1]);
            //get rid of empty values
            foreach ($attributevalues as $key => $value) {
                if (!$value || trim($value) == "") {
                    unset($attributevalues[$key]);
                }
            }
            if (count($attributevalues) >= 1) {
                $attributetype = ProductAttributeType::find_or_make($attributetype);
                foreach ($attributevalues as $key => $value) {
                    $val = trim($value);
                    if ($val != "" && $val != null) {
                        $attributevalues[$key] = $val;
                        //remove outside spaces from values
                    }
                }
                $attributetype->addValues($attributevalues);
                $obj->VariationAttributeTypes()->add($attributetype);
                //only generate variations if none exist yet
                if (!$obj->Variations()->exists() || $obj->WeAreBuildingVariations) {
                    //either start new variations, or multiply existing ones by new variations
                    $obj->generateVariationsFromAttributes($attributetype, $attributevalues);
                    $obj->WeAreBuildingVariations = true;
                }
            }
        }
    }