Jump to content

Building Combinations Programmatically


dhurley

Recommended Posts

Hi all.

 

I have built an importer that takes a csv from the suppler. Then converts it into a csv file that presta can digest. Everything works fine except it now displays the same image for each size. So if there are several sizes, it will display the same color image for each size.

 

Loads slowly but here you go, have a look:

 

http://ps.outletshirts.com/t-shirts/youth-ultra-cotton-100-cotton-t-shirt.html

 

Here is the bit of code that is being used to build the csv. First part is just column references.

 

#id_product | group | attribute | reference | wholesale_price | price | quantity | minimal_quantity | weight | default_on | image_url | delete_existing_images | ecotax| ean13 | upc | id_shop
$putcsv = array(
			    $prodId,
			    "Color:color:0, Size:select:1",
			    $this->alphaNumOnly($data["COLOR_NAME"]).":0, ".$this->alphaNumOnly($data["SIZE"]).":1",
			    $data["UNIQUE_KEY"],
			    $price_wholesale,
			    $price_retail,
			    $data["QTY"],
			    "1",
			    $data["PIECE_WEIGHT"],
			    $default,
			    $image,
		    "1",
		    "",
		    "",
		    "",
		    "1");
	    fputcsv($file_resource, $putcsv, ";");

 

Thanks for your help!

Link to comment
Share on other sites

I would expect you have to add the images to an array, indexable with the sizes. Then when you add size S, use $myImagesArray as image, adding size 'M', use $myImageArray[M] etc.

 

so in the code something like similar to

 

...

$data["PIECE_WEIGHT"],

$default,

$myImageArray[sizeVariable],

...

where sizeVariable holds the S, M, L etc,

 

My 2 cents,

pascal

Link to comment
Share on other sites

Thanks for your reply.

 

Looking at the examples for other input types of csv files you see that the presta looks for nested arrays like this:

 

whatever; whatever; image1,image2,image3; whatever...

 

I don't know how I would associate an index with these images.

 

whatever; whatever; small:image1,medium:image2,large:image3; whatever...

 

I don't think that will work. Also from the example data it does not say that the images field supports an array.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...