<?php
private function _meta($type,$props,$variation=false) {
$fields = array();
switch ($type) {
case "product":
$_attributes = [
"MyCustomAttribute" => [
"name" => "MyCustomAttribute",
"value" => "The Value",
"position" => 1,
"is_visible" => 0,
"is_variation" => 0,
"is_taxanomy" => 0
]
}
$fields = array(
"algolia_posts_product_records_count" => 1,
"_sku" => $props["sku"],
"_sale_price_dates_from" => "",
"_sale_price_dates_to" => "",
"total_sales" => 0,
"_tax_status" => "taxable",
"_tax_class" => "",
"_manage_stock" => "no",
"_backorders" => "no",
"_sold_individually" => "no",
"_weight" => "",
"_length" => "",
"_width" => "",
"_height" => "",
"_upsell_ids" => "a:0:{}",
"_crosssell_ids" => "a:0:{}",
"_purchase_note" => "",
"_default_attributes" => "a:0:{}",
"_virtual" => "no",
"_downloadable" => "no",
"_product_image_gallery" => "",
"_download_limit" => "0",
"_download_expiry" => "0",
"_thumbnail_id" => $props["attachment_id"],
"_low_stock_amount" => "",
"_stock" => null,
"_stock_status" => "instock",
"_wc_average_rating" => $props["_wc_average_rating"],
"_wc_rating_count" => "1",
"_wc_review_count" => "1",
"_downloadable_files" => "a:0:{}",
"_product_attributes" => serialize($_attributes),
"_product_version" => "3.5.7",
"_price" => $props["sale_price"],
"_regular_price" => $props["regular_price"],
"_sale_price" => $props["sale_price"],
"_edit_lock" => "",
"_sold_individually" => "no"
);
if ($variation) $fields["_default_attributes"] = serialize(["variant"=>$props["variant"]]);
break;
case "variant":
$fields = array(
"_variation_description" => "",
"_sku" => "",
"_regular_price" => $props["regular_price"],
"_sale_price" => $props["sale_price"],
"_sale_price_dates_from" => "",
"_sale_price_dates_to" => "",
"total_sales" => "0",
"_tax_status" => "taxable",
"_tax_class" => "parent",
"_manage_stock" => "no",
"_backorders" => "no",
"_sold_individually" => "no",
"_weight" => "",
"_length" => "",
"_width" => "",
"_height" => "",
"_upsell_ids" => "a:0:{}",
"_crosssell_ids" => "a:0:{}",
"_purchase_note" => "",
"_default_attributes" => "a:0:{}",
"_virtual" => "no",
"_downloadable" => "no",
"_product_image_gallery" => "",
"_download_limit" => "0",
"_download_expiry" => "0",
"_thumbnail_id" => $props["_thumbnail_id"],
"_low_stock_amount" => "",
"_stock" => null,
"_stock_status" => "instock",
"_wc_average_rating" => "0",
"_wc_rating_count" => "a:0:{}",
"_wc_review_count" => "0",
"_downloadable_files" => "a:0:{}",
"attribute_variant" => $props["variant"],
"_price" => $props["sale_price"],
"_product_version" => "3.5.7"
);
break;
case "attachment":
$file = sprintf(\'%d/%d/%s\',date(\'Y\'),date(\'m\'),$props["image"]."jpg");
$data = [
"width" => 1,
"height" => 1,
"file" => $file,
"meta_data" => [
"aperture" => "0",
"credit" => "",
"camera" => "",
"caption" => "",
"created_timestamp" => "0",
"copyright" => "",
"focal_length" => "0",
"iso" => "0",
"shutter_speed" => "0",
"title" => "",
"orientation" => "0"
]
];
$fields = array(
"_wp_attached_file" => $file,
"_wp_attachment_metadata" => serialize($data),
"_wc_attachment_source" => $props["url"]
);
break;
}
return $fields;
}
?>