magento2.2.2 – Magento 2 Cron job Impossible to get the final price

I have the following text in my cron file and the following controller file which is exactly the same code and it gets the price when I load in the URL, but it refuses to get the price in the cron file.

I can get the name very well but no price

enter the description of the image here

_productCollectionFactory = $ productCollectionFactory;
$ this -> _ stockItemRepository = $ stockItemRepository;
$ this -> _ fileSystem = $ file system;
$ this -> _ storeManager = $ storeManager;
$ this -> _ imageHelper = $ imageHelper;
$ this -> _ stockRegistry = $ stockRegistry;
}

public function execute ()
{
$ mediaProductUrl = $ this -> _ storeManager-> getStore () -> getBaseUrl ( Magento  Framework  UrlInterface :: URL_TYPE_MEDIA). & # 39; catalog / product & # 39 ;;
$ placeholderImageUrl = $ this -> _ imageHelper-> getDefaultPlaceholderUrl (& # 39;);
$ content = & # 39;
$ fileName = & # 39; test & # 39 ;;
$ productCollection = $ this-> getProductCollection ();
foreach ($ productCollection as $ product) {
if ($ product-> getTypeId () == & # 39; configurable & # 39;) {
$ productCstock = $ this-> getStockItem ($ product-> getId ());
$ prices = $ product-> getPriceInfo () -> getPrice (& # 39; final_price & # 39;) -> getAmount () -> getValue ();
$ content. = & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. price in $. & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. $ product-> getName (). & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. PHP_EOL;
$ configChild = $ product-> getTypeInstance () -> getUsedProducts ($ product);
foreach ($ configChild as $ child) {
$ productStock = $ this-> getStockItem ($ product-> getId ());
$ content. = & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. price in $. & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. $ product-> getName (). & # 39;& # 39 ;. PHP_EOL;
$ content. = & # 39;& # 39 ;. PHP_EOL;
}
}
}
$ feed = $ this-> createHeader (). $ content. $ this-> createFooter ();
$ media = $ this -> _ file system -> getDirectoryWrite ( Magento  Framework  App  File System  DirectoryList :: MEDIA);
$ media-> writeFile ("customFeed /". $ fileName. ".xml", $ feed);

}
return $ this;
}

public function getProductCollection ()
{
$ collection = $ this -> _ productCollectionFactory-> create ();
$ collection-> addAttributeToSelect (& # 39; * & # 39;);
return $ collection;
}

public function getStockItem ($ productId)
{
return $ this -> _ stockRegistry-> getStockStatus ($ productId);
}

public service createHeader ()
{
$ header = & # 39;& # 39 ;. PHP_EOL;
$ header. = & # 39;& # 39 ;. PHP_EOL;
$ header. = & # 39;& # 39 ;. PHP_EOL;
return $ header;
}

public function createFooter ()
{
$ footer = & # 39;& # 39 ;. PHP_EOL;
$ footer. = & # 39;& # 39 ;. PHP_EOL;
return $ footer;
}

}

I've also tried different methods such as getFinalPrice () but no luck in cron. This only works in the controller.

Someone knows what I could miss in Cron getting a price?