function generateVariants(){
		// console.log($scope.product.attr1_values);
		let variant = [];
		if($scope.product.attr1_values == undefined || $scope.product.attr1_values.length == 0 )
			return;
		_sku = init_sku;

		
		$scope.counter = $scope.currentSequenceNumber;
		$scope.counter++;
		$scope.name_counter = $scope.product.product_variants.length;
		$scope.custom_sku = $scope.product.product_variants[$scope.product.product_variants.length - 1].sku;
		// console.log($scope.name_counter);
		// console.log($scope.custom_sku);
		/*
		*/

			let matcher = '';
		for(let i = 0; i < $scope.product.attr1_values.length; i++ ){
			matcher = `${$scope.product.attr1_values[i]}`;
			


			if($scope.product.attr2_values.length == 0){
				variant.push(matcher)
				continue;
			}

			for(let j = 0; j < $scope.product.attr2_values.length; j++ ){
				matcher = `${$scope.product.attr1_values[i]} ${$scope.product.attr2_values[j]}`;
				

				if($scope.product.attr3_values.length == 0){
					variant.push(matcher);
					continue;
				}

				for(let k = 0; k < $scope.product.attr3_values.length; k++ ){
					matcher = `${$scope.product.attr1_values[i]} ${$scope.product.attr2_values[j]} ${$scope.product.attr3_values[k]}`;

					variant.push(matcher);
				}
			}
		}
		
			// console.log(variant);
			let modified_var = [];
		let modified_variants = [...$scope.product.product_variants.map(item => {
			let attri_vals = `${item.attribute_value_1} ${item.attribute_value_2} ${item.attribute_value_3}`;
			// modified_var.push(attri_vals);
			if(variant.includes(attri_vals)){
				return	item;
			}
		})];

		let attr_values = []
		variant.map(it =>{
			$scope.product.product_variants.map(item =>{
			let attri_vals = `${item.attribute_value_1} ${item.attribute_value_2} ${item.attribute_value_3}`;
				attr_values.push(attri_vals);
			})
		})
		let attr_valuess = Array.from(new Set(attr_values));
		let difference = variant.filter(x => !attr_valuess.includes(x));
		let new_var = [];
			console.log(difference);
		difference.map(it => {
			console.log(it.split(' ')[0]);
			if(it.split(' ')[0] == `${$scope.new_attr}` && `${$scope.new_attr}` != undefined){
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
				let set_value = $scope.setValue(new_var);
					$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);

			}
			if(it.split(' ')[1] == `${$scope.new_attr}` && `${$scope.new_attr}` != undefined){
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
				let set_value = $scope.setValue(new_var);
					$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);
			}
			if(it.split(' ')[2] == `${$scope.new_attr}` &&  `${$scope.new_attr}` != undefined){
				console.log(`${$scope.new_attr}`);
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);

				let set_value = $scope.setValue(new_var);
				$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);
			}
			// new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
			// console.log(new_var);
			
		})

	}
/*
	* This function Generates Vairants 
	* by mapping all attributes 
	* possible values
	*/
This function Generates Vairants
by mapping all attributes
possible values
This function Generates Vairants by mapping all attributes possible values
function generateVariants(){
		let variant = [];
		if($scope.product.attr1_values == undefined || $scope.product.attr1_values.length == 0 )
			return;
		_sku = init_sku;
		$scope.counter = $scope.currentSequenceNumber;
		$scope.counter++;
		$scope.name_counter = $scope.product.product_variants.length;
		$scope.custom_sku = $scope.product.product_variants[$scope.product.product_variants.length - 1].sku;
			let matcher = '';
		for(let i = 0; i < $scope.product.attr1_values.length; i++ ){
			matcher = `${$scope.product.attr1_values[i]}`;
			if($scope.product.attr2_values.length == 0){
				variant.push(matcher)
				continue;
			}
			for(let j = 0; j < $scope.product.attr2_values.length; j++ ){
				matcher = `${$scope.product.attr1_values[i]} ${$scope.product.attr2_values[j]}`;
				if($scope.product.attr3_values.length == 0){
					variant.push(matcher);
					continue;
				}
				for(let k = 0; k < $scope.product.attr3_values.length; k++ ){
					matcher = `${$scope.product.attr1_values[i]} ${$scope.product.attr2_values[j]} ${$scope.product.attr3_values[k]}`;
					variant.push(matcher);
				}
			}
		}
			let modified_var = [];
		let modified_variants = [...$scope.product.product_variants.map(item => {
			let attri_vals = `${item.attribute_value_1} ${item.attribute_value_2} ${item.attribute_value_3}`;
			if(variant.includes(attri_vals)){
				return	item;
			}
		})];
		let attr_values = []
		variant.map(it =>{
			$scope.product.product_variants.map(item =>{
			let attri_vals = `${item.attribute_value_1} ${item.attribute_value_2} ${item.attribute_value_3}`;
				attr_values.push(attri_vals);
			})
		})
		let attr_valuess = Array.from(new Set(attr_values));
		let difference = variant.filter(x => !attr_valuess.includes(x));
		let new_var = [];
			console.log(difference);
		difference.map(it => {
			console.log(it.split(' ')[0]);
			if(it.split(' ')[0] == `${$scope.new_attr}` && `${$scope.new_attr}` != undefined){
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
				let set_value = $scope.setValue(new_var);
					$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);
			}
			if(it.split(' ')[1] == `${$scope.new_attr}` && `${$scope.new_attr}` != undefined){
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
				let set_value = $scope.setValue(new_var);
					$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);
			}
			if(it.split(' ')[2] == `${$scope.new_attr}` &&  `${$scope.new_attr}` != undefined){
				console.log(`${$scope.new_attr}`);
				new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]);
				let set_value = $scope.setValue(new_var);
				$scope.product.product_variants.push(new_var);
				$scope.product.variants.push(new_var);
			}
		})
	}
function generateVariants ( ) { let variant = [ ] ; if ( $scope . product . attr1_values == undefined || $scope . product . attr1_values . length == 0 ) return ; _sku = init_sku ; $scope . counter = $scope . currentSequenceNumber ; $scope . counter ++ ; $scope . name_counter = $scope . product . product_variants . length ; $scope . custom_sku = $scope . product . product_variants [ $scope . product . product_variants . length - 1 ] . sku ; let matcher = '' ; for ( let i = 0 ; i < $scope . product . attr1_values . length ; i ++ ) { matcher = ` ${ $scope . product . attr1_values [ i ] } ` ; if ( $scope . product . attr2_values . length == 0 ) { variant . push ( matcher ) continue ; } for ( let j = 0 ; j < $scope . product . attr2_values . length ; j ++ ) { matcher = ` ${ $scope . product . attr1_values [ i ] } ${ $scope . product . attr2_values [ j ] } ` ; if ( $scope . product . attr3_values . length == 0 ) { variant . push ( matcher ) ; continue ; } for ( let k = 0 ; k < $scope . product . attr3_values . length ; k ++ ) { matcher = ` ${ $scope . product . attr1_values [ i ] } ${ $scope . product . attr2_values [ j ] } ${ $scope . product . attr3_values [ k ] } ` ; variant . push ( matcher ) ; } } } let modified_var = [ ] ; let modified_variants = [ ... $scope . product . product_variants . map ( item => { let attri_vals = ` ${ item . attribute_value_1 } ${ item . attribute_value_2 } ${ item . attribute_value_3 } ` ; if ( variant . includes ( attri_vals ) ) { return item ; } } ) ] ; let attr_values = [ ] variant . map ( it => { $scope . product . product_variants . map ( item => { let attri_vals = ` ${ item . attribute_value_1 } ${ item . attribute_value_2 } ${ item . attribute_value_3 } ` ; attr_values . push ( attri_vals ) ; } ) } ) let attr_valuess = Array . from ( new Set ( attr_values ) ) ; let difference = variant . filter ( x => ! attr_valuess . includes ( x ) ) ; let new_var = [ ] ; console . log ( difference ) ; difference . map ( it => { console . log ( it . split ( ' ' ) [ 0 ] ) ; if ( it . split ( ' ' ) [ 0 ] == ` ${ $scope . new_attr } ` && ` ${ $scope . new_attr } ` != undefined ) { new_var = makeVariant ( it . split ( ' ' ) [ 0 ] , it . split ( ' ' ) [ 1 ] , it . split ( ' ' ) [ 2 ] ) ; let set_value = $scope . setValue ( new_var ) ; $scope . product . product_variants . push ( new_var ) ; $scope . product . variants . push ( new_var ) ; } if ( it . split ( ' ' ) [ 1 ] == ` ${ $scope . new_attr } ` && ` ${ $scope . new_attr } ` != undefined ) { new_var = makeVariant ( it . split ( ' ' ) [ 0 ] , it . split ( ' ' ) [ 1 ] , it . split ( ' ' ) [ 2 ] ) ; let set_value = $scope . setValue ( new_var ) ; $scope . product . product_variants . push ( new_var ) ; $scope . product . variants . push ( new_var ) ; } if ( it . split ( ' ' ) [ 2 ] == ` ${ $scope . new_attr } ` && ` ${ $scope . new_attr } ` != undefined ) { console . log ( ` ${ $scope . new_attr } ` ) ; new_var = makeVariant ( it . split ( ' ' ) [ 0 ] , it . split ( ' ' ) [ 1 ] , it . split ( ' ' ) [ 2 ] ) ; let set_value = $scope . setValue ( new_var ) ; $scope . product . product_variants . push ( new_var ) ; $scope . product . variants . push ( new_var ) ; } } ) }
This function Generates Vairants
 by mapping all attributes
 possible values
This function Generates Vairants by mapping all attributes possible values
// console.log($scope.product.attr1_values); // console.log($scope.name_counter); // console.log($scope.custom_sku); /*
		*/ // console.log(variant); // modified_var.push(attri_vals); // new_var = makeVariant(it.split(' ')[0],it.split(' ')[1],it.split(' ')[2]); // console.log(new_var);