Vinai / groupscatalog2

Magento extension to enable you to hide categories and products from customers depending on their customer group. This is a Magento 1.6 and newer compatible version of the Netzarbeiter Customer Groups Catalog extension.
139 stars 59 forks source link

How to set multivalue of "groupscatalog2_groups" via API Soap v2 #109

Open serifreedom opened 9 years ago

serifreedom commented 9 years ago

Hello Vinai, I have to set attribute groupscatalog2_groups value via API, Can I do that? if yes then how? I've tried something like this(c# .net) :

    additional_attributes = new catalogProductAdditionalAttributesEntity()
    {
        single_data = new associativeEntity[2]
        {
            new associativeEntity(){key = "color",value ="White"}, new associativeEntity(){key = "size",value="M"}                                                              
        },
        multi_data = new associativeMultiEntity[1] 
        {
            new associativeMultiEntity()
            {
                key ="groupscatalog2_groups",
                value = new String[2]{"NOT LOGGED"IN","Wholesale"}
            }
        }
    }

color & size works but groupscatalog2_groups did not work! both Id or label

Vinai commented 9 years ago

Hm, interesting.
Which API method are you calling? catalogProduct.create or catalogProduct.update? I would have to debug what happens in Mage_Catalog_Model_Product_Api_V2::_prepareDataForSave(), in the additional_attributes branch of the code. If all is parsed correctly there, I'd look into the call to $product->validate().

Since I'm not familiar with C# its not that easy to reproduce your use case, since I'm unsure if the matching PHP code would actually generate the same SOAP payload.

Vinai commented 9 years ago

On a side note, I know some people had issues with importing the attribute value NOT LOGGED IN customer group, which mapps to the ID 0 (zero).
This hardcoded choice fails some validation. Just to test, maybe try setting only customer groups with ID values larger then zero, to see if that is causing the problem?

serifreedom commented 9 years ago

HI Vinai, Thank you for quickly reply, I'm newbie with magento, I didn't figure out most of your commented, I'll try: Q: Which API method are you calling? A: - catalog_product.create (SOAP V1)

Vinai commented 9 years ago

Lets keep the discussion here, that way someone else with a similar problem might benefit from it in future. Please let me know if you have some success with a call that doesn't use the NOT LOGGED IN group. If you are able to dump the XML sent to the Magento endpoint and post it here, that might be helpful, too. If I have time I'll write a little php script to call the API in order to reproduce the problem, but currently, especially before christmas, there is a lot going on, so please don't count on that happening.

Regarding the NOT LOGGED IN group with the ID 0, during the import I think a small patch of a core Magento file was required. I'll see if I can find the issue.

Vinai commented 9 years ago

This was the issue thread i was thinkning of. But please keep in mid that it might not be related at all, as here we are dealing with the API. If you are encountering the same issue, then a test without NOT LOGGED IN should actually work. If it doesn't, then this is not related. https://github.com/Vinai/groupscatalog2/issues/25#issuecomment-31754306