Running a custom import script, I'm facing this error for some products (some others are perfectly being created without this issue).

  • Error occured on B2C product import : The product that was requested doesn't exist. Verify the product and try again.

#0 /var/www/html/generated/code/Magento/Catalog/Model/ProductRepository/Interceptor.php(32): Magento\Catalog\Model\ProductRepository->getById(1170, false, NULL, false)

Doing further digging into this we managed to discover the real issue was this one once the request arrives to the database.

ERROR 1366 (22007): Incorrect integer value: '' for column project-preprod_db.catalog_product_entity.has_options at row 1 ERROR 1366 (22007): Incorrect integer value: '' for column project-preprod_db.catalog_product_entity.required_options at row 1

In the request

INSERT INTO catalog_product_entity (entity_id, attribute_set_id, type_id, sku, has_options, required_options, created_at, updated_at) VALUES (NULL, '9', 'simple', '4194-EU-SI-NE', '', '', '2022-05-13 12:53:09', '2022-05-13 12:53:09');

For some reasons the fields has_options, required_options are empty. If i fill them and launch the same request, then it will work.

But my issue is that I don't understand why for some products i'm getting this error on my magento import, while for others I don't.

Considering magento already seems to handle this columns, it makes no sense they are empty (false doesn't mean empty) : vendor/magento/module-catalog/Model/Product.php

public function beforeSave()

This is the code being used to set all the product attribute before saving it to the repository method

            $mageProduct = $this->getProductBySku($sku);
                ->setTaxClassId(($apiProduct['modelType'] == 'Machine' || $apiProduct['modelType'] == 'Product') ? 11 : 10)
                ->setCategoryIds(explode(',', $categories))

 * @param string $sku
 * @return \Magento\Catalog\Api\Data\ProductInterface
protected function getProductBySku($sku)
    try {
        $product = $this->productRepository->get($sku);
    } catch (NoSuchEntityException $e) {
        $product = $this->productFactory->create();
    return $product;

1 Answer 1


can you try (if you haven't already) setting has_options and required_options to 0 . Maybe Mysql interprates the empty value as null and this field is set to notNull.

  • First things i tried. I tried 0 and 1. I tried in my import script and inside the save method from the repository. Nothing change. That being said we are not supposed to set these value anyway they are calculated on the beforeSave automatically...at least they should be.
    – Claims
    Commented May 18, 2022 at 15:01
  • Are you trying to update or create products or both? Commented May 19, 2022 at 9:23
  • For creation are you using Factory ? Commented May 19, 2022 at 9:27
  • Both but in that specific case i'm just speaking about creation. I'm adding the method used in the question.
    – Claims
    Commented May 19, 2022 at 12:03
  • What version of magento are you using, mybe its a bug that been solved in the next versions ? Also try disabling modules which are not included in the plain magento installation, maybe some of theme have a functionality which breaks your import. Commented May 20, 2022 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.