You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Quick side note on how to quickly replicate the issue on Magento 2:
This is a quick dirty script I've created in order to show the problem on M2:
Create the following file: /dev/tests/unit/test.php:
<?php
require "../../../app/bootstrap.php";
class Test extends \PHPUnit_Framework_TestCase
{
public function testExample()
{
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$obj = $bootstrap->getObjectManager();
$prod = $obj->create('\Magento\Catalog\Model\ProductFactory');
$col = $prod->create()->getCollection()->addAttributeToSelect('tax_class_id')->addAttributeToSort('name')->addAttributeToSelect('price')->setPageSize(1);
var_dump($col->getFirstItem()->getData('tax_class_id'));
$col = $prod->create()->getCollection()->addAttributeToSelect('tax_class_id')->addAttributeToSort('name')->setPageSize(1);
var_dump($col->getFirstItem()->getData('tax_class_id'));
}
}
When you run phpunit test.php from the dev/tests/unit folder, you will get the following result:
string(1) "2"
string(6) "2.0000"
As you can see, without the addAttributeToSelect('price') call, the result is what we expect, the value of the tax_class_id attribute as it is supposed to be: an integer.
However, when you add the addAttributeToSelect('price'), the result differs and we get a tax_class_id value casted as a decimal.
Everything you need to know is listed under this Magento Stack Exchange question: http://magento.stackexchange.com/questions/105244/magento-1-admin-product-grid-column-value-disappear-on-name-search/105421
Even though the question I asked was about Magento 1, it seems like this bug is still present in Magento 2 and I'm about to make a PR to fix it.
The text was updated successfully, but these errors were encountered: