Skip to content

Instantly share code, notes, and snippets.

@whatafunc
Last active May 18, 2023 06:41
Show Gist options
  • Save whatafunc/a3d4147d0b222a41fea8f5720f2c841b to your computer and use it in GitHub Desktop.
Save whatafunc/a3d4147d0b222a41fea8f5720f2c841b to your computer and use it in GitHub Desktop.
$data = [
[
'sku' => 'test2',
'name' => 'Big TV',
'description' => 'ma tEsEt descr',
'price' => 15000, // in cents
'sale_price' => 129900,
'sale_price_from' => '2019-08-07 18:11:31+02:00',
'sale_price_until' => '2019-10-01 01:00:00+02:00',
'stock' => 14,
'weight' => 15.50,
'weight_unit' => 'kg',
'length_unit' => 'cm',
'image' => '/assets/components/gg/img/logo.svg',
'properties' => serialize([
'product_with_alcohol' => 0,
'extra_details' => [
'image_alt_0' => 'abc',
'image_1' => '/assets/products/images/1.jpg',
'image_alt_1' => '#$%^',
'image_2' => '/assets/products/images/2.jpg',
'image_alt_2' => '12',
'image_3' => '/assets/products/images/3.jpg',
'image_alt_3' => '',
'image_4' => '',
'image_alt_4' => '',
'image_5' => '',
'image_alt_5' => '',
'video_url' => '',
'youtube_id' => '',
]
]),
'width' => 12.50,
'height' => 11.50,
'depth' => 10.50,
],
@whatafunc
Copy link
Author

whatafunc commented May 18, 2023

OK, the correct $stmt should be
$sql = "INSERT into modx_tagger_tagsSETtag= '".$tag ."',label= '".$tag."',alias= '". strtolower($tag) ."',group` = '". ($ktag== 'merk' ? $modx_tagger_groups['merk'] : $modx_tagger_groups['categorie']) ."' ";
$stmt = $modx->prepare($sql); #echo $sql;
if ($stmt->execute()) {
echo '\n
tags & labels INSERTED OK
';
$tagID = $modx->lastInsertId($stmt); echo '<is the tagID
';

				} else {
		 			echo '\n <br /> tags & labels NOT INSERTED OK <br />'. $stmt->error; print_r($stmt->errorInfo());
				}
				$stmt->closeCursor();`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment