1

I'm very new to DC; trying to collect user id and SKU data from the checkout completed tab to upload it to S3. It appears that as soon as I gather the data and write to user.txt file DC crashes with Entity Meta Data Exception. Greatly appreciate any direction on how to do it correctly.

(No problem in uploading data to S3, it works from the script and the user.txt file is generated correctly).

<?php

 function getproductfile_commerce_checkout_complete($order) {

 $s3file = fopen("/var/tmp/user.txt","a");
 $ow = entity_metadata_wrapper('commerce_order', $order);


 foreach ($ow->commerce_line_items as $line_item) {
 $sku = $line_item->commerce_product->sku->value();
 $Usr_name = $line_item->order->owner->label();
 $usr_name = strtolower($Usr_name);

 $txt1 = $sku.$usr_name;

 fwrite($s3file, $txt1);
 fwrite($s3file, "\n");

 }

 fclose($s3file);

// UPLOAD FILES TO S3
 $out = shell_exec("sudo aws s3 cp /var/tmp/user.txt s3://user_data_bucket_2015");

} ?>

EntityMetadataWrapperException: Unknown data property commerce_product.   in   EntityStructureWrapper->getPropertyInfo() (line 335  of /var/www/.../profiles/commerce_kickstart/modules/contrib/entity/includes/entity.wrapper.inc).
ASG
  • 39
  • 1
  • 4

0 Answers0