我对 DC 很陌生;尝试从结帐完成选项卡收集用户 ID 和 SKU 数据以将其上传到 S3。看来,一旦我收集数据并写入 user.txt 文件,DC 就会因实体元数据异常而崩溃。非常感谢有关如何正确执行此操作的任何指导。
(将数据上传到 S3 没有问题,它从脚本工作并且正确生成了 user.txt 文件)。
<?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).