Magento 2.0 API Issue in Attribute Set

Everyone is trying hard to work on the all new Magento 2.0 eCommerce Platform which Magento rolled out in Q4 2015. It’s a completely new architecture to work upon for core development, design and Integration. To cater our product roadmap of releasing Magento 2.0 Integration with popular ERP systems such as SAP Business One, MS Dynamics NAV; we are working deeply in the API level, finding out many issues and developing solutions to resolve that. Below is one such issue which we would like to mention, we believe the issue and it’s solution will help other Magento Partners.

ISSUE MAGENTO 2: REST API: GET /V1/products/attribute-sets/{attributeSetId}/attributes does not work for any new attribute set.

Details:

If any new attribute set is created and REST API: GET /V1/products/attribute-sets/{attributeSetId}/attributes is executed then it throws an error:
Error:
{
“message”: “Internal Error. Details are available in Magento log file. Report ID: webapi-574ed41d7eb6e”
}

1

Solution

integrate-magento-with-ERP-2

Go to
/vendor/magento/module-eav/Model/Entity/Attribute/ AbstractAttribute.php
Search for _getDefaultSourceModel() method and modify it as given in the below picture.

2

Just comment/remove the original code (line no. 587) and replace it with:
return $this->getEntityType()->getEntity()->getDefaultAttributeSourceModel();

Explanation

getEntityType() was missing in the original code because of which it was not able to return the value/attributes of any newly created attribute-set other than the default one.

become-appseconnect-partner

author avatar
Atul Gupta CEO and Co-Founder
Atul Gupta is the Co-Founder & CEO of APPSeCONNECT, with nearly two decades building enterprise integration and automation technology. A recognized voice in the iPaaS, B2B eCommerce, and business process automation space, he has scaled solutions trusted by 1,500+ businesses across 75+ countries. Former Chairman of NASSCOM's Eastern Region SME Council, Atul writes on connected business, ERP integration, and digital transformation.