Hi,
I'm trying to create a product using a rabbitmq consumer
the product is being created and assigned an id but when the script reaches
$this->_eventManager->dispatch($this->_eventPrefix . '_save_after', $this->_getEventData());
on the
Magento\Framework\Model\Abstract
class theres a part that tries to load the product from the db, but no commit was done yet
i tried using the deprecated product->save() method and the resource save method and the repository save method all with the same result
public function processMessage(InventoryItemInterface $item)
{
parent::processMessage($item);
// $this->_emulation->startEnvironmentEmulation(0,\Magento\Framework\App\Area::AREA_ADMINHTML);
/** @var ProductInterface $product */
$product = $this->_productFactory->create();
$product->setTypeId("4");
$product->setStoreId(0);
$product->setData('_edit_mode', true);
$product->setSku($item->getSku());
$product->setName(self::NEW_PRODUCT_TITLE . $item->getSku());
$product->setPrice($item->getPrice());
$product->setSpecialPrice($item->getSpecialPrice());
if ((int)$item->getInventoryReady()) {
$product->setQty($item->getInventoryReady());
} else {
$product->setQty($item->getInventoryBeingShipped());
}
$arrivalMessage = $this->getArrivalMessage($item);
$product->setData(UpgradeData::INVENTORY_MESSAGE, $arrivalMessage);
$product->setStatus(Status::STATUS_DISABLED);
$product->setAttributeSetId($product->getDefaultAttributeSetId());
$product->setStockData([
'use_config_manage_stock' => 0,
'qty' => 0,
'is_qty_decimal' => 0,
'manage_stock' => 1,
'is_in_stock' => 0
]);
$product->setQuantityAndStockStatus([
'use_config_manage_stock' => 0,
'qty' => 0,
'is_qty_decimal' => 0,
'manage_stock' => 1,
'is_in_stock' => 0
]);
try {
$this->_resourceProduct->save($product);
// $this->_productRepositoryInterface->save($product, false);
// $this->_emulation->stopEnvironmentEmulation();
} catch (\Exception $ex) {
$this->_logger->error($ex->getMessage());
}
}
i also tried emulation of areas but with no change
cleared cache, generated, restarted mysql, reindexed data
what am i missing?
magento version 2.3.4
thanks