Skip to content

Magento 2 product attribute source issue #23828

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Naberdz opened this issue Jul 23, 2019 · 7 comments
Closed

Magento 2 product attribute source issue #23828

Naberdz opened this issue Jul 23, 2019 · 7 comments
Assignees
Labels
Event: mm19pl Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed

Comments

@Naberdz
Copy link

Naberdz commented Jul 23, 2019

Preconditions (*)

  1. Magento 2.3.2
  2. PHP 7.2

Steps to reproduce (*)

  1. Create product attribute with source model
<?php
namespace Vendor\Module\Setup;

use Magento\Catalog\Setup\CategorySetup;
use Magento\Eav\Setup\EavSetup;
use Magento\Eav\Model\Entity\Attribute\ScopedAttributeInterface;
use Magento\Catalog\Model\ResourceModel\Product\Attribute\Collection;
use Magento\Catalog\Model\ResourceModel\Eav\Attribute;
use Magento\Catalog\Model\ResourceModel\Product;

class ProductSetup extends EavSetup
{

	public function getDefaultEntities()
	{
		return [
			'catalog_product' => [
				'entity_type_id' => CategorySetup::CATALOG_PRODUCT_ENTITY_TYPE_ID,
				'entity_model' => Product::class,
				'attribute_model' => Attribute::class,
				'table' => 'catalog_product_entity',
				'additional_attribute_table' => 'catalog_eav_attribute',
				'entity_attribute_collection' =>
				Collection::class,
				'attributes' => [
					'auto_merk' => [
						'type' => 'varchar',
						'label' => 'Auto Merk',
						'input' => 'multiselect',
						'source' => \Vendo\Module\Model\Product\Source\AutoMerken::class,
						'frontend' => '',
						'required' => false,
						'note' => '',
						'class' => '',
						'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
						'sort_order' => '30',
						'global' => ScopedAttributeInterface::SCOPE_STORE,
						'default' => null,
						'visible' => true,
						'user_defined' => true,
						'searchable' => true,
						'filterable' => true,
						'comparable' => false,
						'visible_on_front' => true,
						'unique' => false,
						'apply_to' => '',
						'group' => 'General',
						'used_in_product_listing' => true,
						'is_used_in_grid' => false,
						'is_visible_in_grid' => false,
						'is_filterable_in_grid' => false,
					],
					'auto_model' => [
						'type' => 'varchar',
						'label' => 'Auto Model',
						'input' => 'multiselect',
						'source' => \Vendo\Module\Model\Product\Source\AutoModel::class,
						'frontend' => '',
						'required' => false,
						'note' => '',
						'class' => '',
						'backend' => 'Magento\Eav\Model\Entity\Attribute\Backend\ArrayBackend',
						'sort_order' => '30',
						'global' => ScopedAttributeInterface::SCOPE_STORE,
						'default' => null,
						'visible' => true,
						'user_defined' => true,
						'searchable' => true,
						'filterable' => true,
						'comparable' => false,
						'visible_on_front' => true,
						'unique' => false,
						'apply_to' => '',
						'group' => 'General',
						'used_in_product_listing' => true,
						'is_used_in_grid' => false,
						'is_visible_in_grid' => false,
						'is_filterable_in_grid' => false,
					],
				]
			]
		];
	}
}

namespace Vendor\Module\Model\Product\Source;

class AutoMerken extends \Magento\Eav\Model\Entity\Attribute\Source\AbstractSource
{
	protected $_options;
	
	/**
	 * getAllOptions
	 *
	 * @return array
	 */
	public function getAllOptions()
	{
		if ($this->_options === null) {
			$this->_options = [
				['value' => 'ac', 'label' =>  'AC'],
				['value' => 'alfa_romeo', 'label' =>  'Alfa Romeo'],
				['value' => 'aston_martin', 'label' =>	'Aston Martin'],
				//...... and so on
			];
		}
		return $this->_options;
	}
		
	final public function toOptionArray()
	{
		return array(

			array('value' => 'ac', 'label' =>  'AC'),
			array('value' => 'alfa_romeo', 'label' =>  'Alfa Romeo'),
			array('value' => 'aston_martin', 'label' =>	 'Aston Martin'),
			//...... and so on over 50 additional options
		);
	}
}

same functions apply to another source model with over 700 options

  1. Add attribute options to product

Schermafbeelding 2019-07-22 om 13 36 10

Expected result (*)

  1. Indexer should work but gives error.
  2. Product should be visible in frontend.

Actual result (*)

Design Config Grid index has been rebuilt successfully in 00:00:00
Customer Grid index has been rebuilt successfully in 00:00:01
Category Products index has been rebuilt successfully in 00:00:00
Product Categories index has been rebuilt successfully in 00:00:00
Catalog Rule Product index has been rebuilt successfully in 00:00:00
SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '1-136-1-0-1' for key 'PRIMARY', query was: INSERT  INTO `catalog_product_index_eav_temp` (`entity_id`,`attribute_id`,`store_id`,`value`,`source_id`) VALUES (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?), (?, ?, ?, ?, ?)
Stock index has been rebuilt successfully in 00:00:00
Inventory index has been rebuilt successfully in 00:00:00
Catalog Product Rule index has been rebuilt successfully in 00:00:00
Product Price index has been rebuilt successfully in 00:00:00
Catalog Search index has been rebuilt successfully in 00:00:00

Checked database but can't find anything out of order
Schermafbeelding 2019-07-23 om 09 29 12

Schermafbeelding 2019-07-23 om 09 08 28

3. if i remove attributes from product set and save product it gives no error with index and product is visible in frontend.

Schermafbeelding 2019-07-23 om 09 13 41

@m2-assistant
Copy link

m2-assistant bot commented Jul 23, 2019

Hi @Naberdz. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento give me 2.3-develop instance - upcoming 2.3.x release

For more details, please, review the Magento Contributor Assistant documentation.

@Naberdz do you confirm that you were able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed label Jul 23, 2019
@shikhamis11 shikhamis11 self-assigned this Jul 23, 2019
@m2-assistant
Copy link

m2-assistant bot commented Jul 23, 2019

Hi @shikhamis11. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

  • 6. Add label Issue: Confirmed once verification is complete.

  • 7. Make sure that automatic system confirms that report has been added to the backlog.

@magento magento deleted a comment from m2-assistant bot Aug 22, 2019
@manish0592
Copy link

#mm19pl

@magento-engcom-team
Copy link
Contributor

@manish0592 thank you for joining. Please accept team invitation here and self-assign the issue.

@manish0592
Copy link

Hi @Naberdz ,
I'm trying to reproduce this issue by using the steps you mention above, but not able to reproduce.

@ghost ghost unassigned shikhamis11 Sep 27, 2019
@engcom-Charlie engcom-Charlie self-assigned this Sep 30, 2019
@m2-assistant
Copy link

m2-assistant bot commented Sep 30, 2019

Hi @engcom-Charlie. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.3-develop branch

    Details- Add the comment @magento give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-Charlie
Copy link
Contributor

Hello @Naberdz
We are not able to reproduce this issue on the lates 2.3-develop branch by provided steps.
So i have to close this issue.
Thanks for your report!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Event: mm19pl Issue: Format is valid Gate 1 Passed. Automatic verification of issue format passed
Projects
None yet
Development

No branches or pull requests

5 participants