Skip to content

REST API /V1/products/attributes does not update all properties #10205

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
sazzle2611 opened this issue Jul 11, 2017 · 8 comments
Closed

REST API /V1/products/attributes does not update all properties #10205

sazzle2611 opened this issue Jul 11, 2017 · 8 comments
Assignees
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Event: squashtoberfest Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed

Comments

@sazzle2611
Copy link

sazzle2611 commented Jul 11, 2017

Using Magento 2.1.7 with the REST API - POST /V1/products/attributes - I can add a new attribute and configure it with settings such as is_filterable.

This is all fine but if I then want to change this setting I can't. I have tried with POST and with PUT /V1/products/attributes/{attributeCode}. The command works as in it will update, for instance, the frontend label in the eav_attribute table, but it does not seem to have any effect on values in the catalog_eav_attribute table.

Steps to reproduce -

  1. Add a new attribute using REST API - POST - /V1/products/attributes - with is_filterable set to false.
  2. Update the same attribute using either the same POST url or PUT - /V1/products/attributes/{attributeCode} and set the is_filterable field to true

Expected result
The attribute is now set to be filterable

Actual result
No change

@misha-kotov
Copy link

Hi @sazzle2611 thanks for reporting this issue.
Do you mind adding some more details in accordance to our Issue reporting guidelines: with steps to reproduce, actual result and expected result. It will help us reproduce and troubleshoot the issue.

@misha-kotov misha-kotov added 2.1.x bug report Progress: needs update Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Jul 17, 2017
@magento-engcom-team magento-engcom-team added 2.1.x bug report Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Progress: needs update Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog labels Sep 11, 2017
@magento-engcom-team
Copy link
Contributor

@sazzle2611 we are closing this issue due to inactivity. If you'd like to update it, please reopen the issue.

@tkotosz
Copy link
Contributor

tkotosz commented Apr 5, 2018

I can reproduce the same issue in magento 2.2.2. I have tried to update the visibility of an attribute (is_visible_on_front) with POST request to /V1/products/attributes and PUT request to /V1/products/attributes/{attribute_code} but it didn't change the attribute property.

Update: it seems if I do a PUT /V1/products/attributes/{attribute_code} and provide the attribute_id and the entity type id as well then I can change the visibility like this:

{
  "attribute": {
        "is_visible_on_front": "0",
        "attribute_id": 4603,
        "entity_type_id": "4"
    }
}

which is really weird. (note that without the entity_type_id it doesn't work)

@engcom-backlog-nickolas

Hello @sazzle2611, thank you for report. Unfortunately I wasn't able to reproduce this issue.
peek 2018-08-10 10-59
If you'd like to update it, please reopen the issue.

@tkotosz it's correct behaviour. You have to specify entity type id, because is_visible_on_front property related to product entity.

@engcom-backlog-nickolas engcom-backlog-nickolas added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Aug 10, 2018
@lewisvoncken
Copy link
Contributor

@engcom-backlog-nickolas Yeah I understand but still the call is already specified for product attributes based on the API call so why do you still need to add the entity type id to the body request?

@sidolov
Copy link
Contributor

sidolov commented Oct 27, 2018

Hi @sazzle2611. Thank you for your report.
The issue has been fixed in #18622 by @lewisvoncken in 2.3-develop branch
Related commit(s):

The fix will be available with the upcoming 2.3.1 release.

@ghost
Copy link

ghost commented Nov 30, 2018

Hi @sazzle2611 , thank you for you report, this issue has already fixed in 2.3-develop branch, and will be available on 2.3.1 release.

@ghost ghost closed this as completed Nov 30, 2018
@carloricci84
Copy link

On 2.2.3 i made a plugin like this to fix the issue since we can't upgrade to 2.3 yet :

Vendor\Module\di.xml

<type name="Magento\Catalog\Model\Product\Attribute\Repository">
    <plugin name="vendor_attribute_repository_plugin" type="Vendor\Module\Plugin\AttributeRepositoryPlugin" />
</type>

Vendor\ModulePlugin\AttributeRepositoryPlugin.php

namespace Vendor\Module\Plugin;

class AttributeRepositoryPlugin
{

    public function __construct(
        \Magento\Eav\Model\Config $eavConfig
    ) {
        $this->eavConfig = $eavConfig;
    }

    public function beforeSave (\Magento\Catalog\Model\Product\Attribute\Repository $subject, \Magento\Catalog\Api\Data\ProductAttributeInterface $attribute ) {
        $attribute->setEntityTypeId(
            $this->eavConfig
                ->getEntityType(\Magento\Catalog\Api\Data\ProductAttributeInterface::ENTITY_TYPE_CODE)
                ->getId()
        );

        return [$attribute];
    }
}

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Event: squashtoberfest Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed
Projects
None yet
Development

No branches or pull requests

8 participants