I have created a script for import CSV products everything's working perfect but one issue is product video url not set.
<?php
use \Magento\Framework\App\Bootstrap;
include('app/bootstrap.php');
// add bootstrap
$bootstraps = Bootstrap::create(BP, $_SERVER);
$object_Manager = $bootstraps->getObjectManager();
$app_state = $object_Manager->get('\Magento\Framework\App\State');
$app_state->setAreaCode('frontend');
// get date
$today_date = date("m/d/Y");
$added_date = date('m/d/Y',strtotime("+17 day"));
$set_product = $object_Manager->create('\Magento\Catalog\Model\Product');
try{
$set_product->setWebsiteIds(array(1));
$set_product->setAttributeSetId(4);
$set_product->setTypeId('simple');
$set_product->setCreatedAt(strtotime('now'));
$set_product->setName('Test Sample Products');
$set_product->setSku('add-sku-1');
$set_product->setWeight(1.0000);
$set_product->setStatus(1);
$category_id= array('3,4,5');
$set_product->setCategoryIds($category_id);
$set_product->setTaxClassId(0);
$set_product->setPrice(100.99) ;
$set_product->setStockData(
array(
'use_config_manage_stock' => 0,
// checkbox for 'Use config settings'
'manage_stock' => 1, // manage stock
'min_sale_qty' => 1, // Shopping Cart Minimum Qty Allowed
'max_sale_qty' => 2, // Shopping Cart Maximum Qty Allowed
'is_in_stock' => 1, // Stock Availability of product
'qty' => 100 // qty of product
)
);
$set_product->save();
// get id of product
$get_product_id = $set_product->getId();
echo "Upload simple product id :: ".$get_product_id."\n";
}
catch (\Exception $e) {
echo $e->getMessage();
}
$set_product->setVideoUrl('youtub.com/magento');
But it's not working category save and set product video URL?