Matrix

Notes on using DataGrab to import into Matrix fields.

Playa, Matrix, and any Pixel & Tonic fieldtypes are deprecated. If you have a site with an import configured to use them, DataGrab may continue to work, but no future development will be performed on those fieldtypes, and support will not be provided for them if there is an issue importing values into those fields. Playa and Matrix are antiquated and should be switched to Relationship and Grid fields respectively. The specific files no longer supported are:

  • datagrab_matrix.php

  • datagrab_playa.php

  • datagrab_fieldpack_checkboxes.php

  • datagrab_pt_multiselect.php

Configuring the import

The results

Matrix cell types

The beta version currently supports text, date and file cells. Support for other cell types to follow.

Date fields can be formatted in any recognisable date format (YYYY-MM-DD HH:MM:SS is recommended)

Images/files should be uploaded manually to an existing File Upload area and the filename in the data source should be prefixed with the Upload area variable (e.g., https://mysite.com/images/uploads/filename.png if filename.png is in the upload area with the id of 1)

Supported data types

CSV and XML imports are supported. I’ll document these better as the beta progresses. Feel free to contact me in the meantime if you need help.

Example data format are:

XML

<products>
	<product>
		<title>PRODUCT4</title>
		<sku>D</sku>
		<description>Lorem ipsum dolor sit amet…</description>
		<items>
			<item>
				<sku>D1</sku>
				<label>TwoA</label>
				<image>https://mysite.com/images/uploads/bnb5.png</image>
				<rel></rel>
				<date>2012-03-01</date>
			</item>
			<item>
				<sku>D2</sku>
				<label>TwoB</label>
				<image>https://mysite.com/images/uploads/bnb1.png</image>
				<rel></rel>
				<date>2012-03-01</date>
			</item>
		</items>
	</product>
</products>

ie, repeating item elements can be imported into a Matrix. Select the first item in the configuration pulldown, and DataGrab will add the rest

CSV with Matrix rows on separate lines of the file

ID1,"PRODUCT1","Blah, blah, blah.",A1,"OneA","https://mysite.com/images/uploads/bnb1.png","","2011-12-11",12.99
ID1,"PRODUCT1","Blah, blah, blah.",A2,"OneB","https://mysite.com/images/uploads/bnb2.png","","2011-12-11",13.99
ID1,"PRODUCT1","Blah, blah, blah.",A3,"OneC","https://mysite.com/images/uploads/bnb4.png","","2011-12-11",14.99

In the settings assign a unique id (eg, product id) to a custom field. Use that field to check for duplicates and check the Update existing entries setting.

CSV with matrix rows as comma delimited values in a cell

E;"PRODUCT5";"Blah, blah, blah.";"E1,E2";"ThreeA,ThreeB";"https://brandnewbox.co.uk/images/uploads/bnb3.png,https://mysite.com/images/uploads/bnb2.png";"2011-11-04,2010-11-16"

Note, that the 4th to 7th columns each have 2 comma-separated values. Each value will be assigned to a new matrix row.

Last updated