1

I'm issuing a problem with newly created downloadable products on Magento 2.3.1

This store contains about 10k products (phisical and digital) imported from M1

  • Phisical in stock/out of stock is working both for imported and native products
  • Digital in stock/out of stock is working only for M1 imported products.

I compared the records of 2 digital products (1 imported and 1 native) in all %stock% database tables and the only strange things I noticed is that:

  • M2 native downloadable product has several records on cataloginventory_stock_cl table
  • M2 imported downloadable product has no records on cataloginventory_stock_cl table

What is the use of cataloginventory_stock_cl table?

There are other places where I can find to debug this problem?

3

In our case the issue was related to a migration from Magento 1 to Magento 2 via migration data tool. The problem is that default value for the attribute 'links_exist' is 0 in Magento 1. However in Magento 2 default value for 'links_exist' is null. Because of that following validation fails

File: vendor/magento/module-catalog/view/frontend/templates/product/view/addtocart.phtml
Line 13: <?php if ($_product->isSaleable()): ?>

which leads to

File: vendor/magento/module-catalog/Model/Product.php
Line 1805: return $this->isSalable();
Line 1748: $salable = $this->isAvailable();
Line 1766: return $this->_catalogProduct->getSkipSaleableCheck() || $this->getTypeInstance()->isSalable($this);

Last part is important: $this->getTypeInstance()->isSalable($this);. In case of a downloadable product following validation happens:

File: vendor/magento/module-downloadable/Model/Product/Type.php
Line 334: return $this->hasLinks($product) && parent::isSalable($product);

This validation will return false for new created downloadables because of mentioned default value 0 for links_exist.

File: vendor/magento/module-downloadable/Model/Product/Type.php

Line 169-176:

public function hasLinks($product)
{
    $hasLinks = $product->getData('links_exist');
    if (null === $hasLinks) {
        $hasLinks = (count($this->getLinks($product)) > 0);
    }
    return $hasLinks;
}

Here your can see that Magento 2 expects null before even considering counting links.

That all said the issue is only related to newly created downloadables. Imported ones will most likely have a different value for links_exist which will pass mentioned validation.

Our solution was to manually change the default value for links exist in eav_attributes table. This should solve the issue for new downloadables.

Hope I could help.

Edit: This bug is already reported on GitHub see: GitHub Issue.

Edit 2:

For downloadables that were created with a wrong default value for links_exist it is necessary to change the attribute value in catalog_product_entity_int. Following query will help (substitute attribute_id and entity_id appropriately):

UPDATE catalog_product_entity_int SET value=null WHERE attribute_id="attribute id of links_exist" AND entity_id="insert product id here";

You can find attribute_id of links_exist in eav_attribute table.

  • I tried your workaround but it don't worked. screencast.com/t/j2qlgBZCXM0 Not sure if the others "null" values are correct – domfitty Sep 20 at 7:45
  • I also checked catalog_product_entity_int table: M1 downloadable products has links_exist = 1, M2 downloadable products has links_exist = 0. If I update this value to 1, the product became "salable". – domfitty Sep 20 at 7:55
  • I forgot to mention that you have to change values in catalog_product_entity_int for already created downloadables as well. Sorry for that. I will update my answer in a minute. – mbernt - mediarox Sep 20 at 8:25
  • after applying workaround, newly created produts has links_exist = 0 – domfitty Sep 20 at 8:30
  • Try cleaning/flushing cache and reindex. – mbernt - mediarox Sep 20 at 8:46
1

cl ending on the table means "chanage log".

Run:

php bin/magento indexer:reindex

And you should be able to see changes in those tables. The above command should hopefully fix the problem with the OOS products.

Have a look at this: Magento 2 Tables Being Created Ending in "_cl"

  • I manually reindexed several times trying also do prior invalidate this indexes with no success. :-( – domfitty Sep 5 at 14:48
  • What do you see when you do reindex:status? – Greg Sep 5 at 14:49
  • All indexes are ready – domfitty Sep 5 at 14:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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