PizzaMartijn
PizzaMartijn

Reputation: 122

Cannot set group price on new magento products from the xml-rpc api

I'm trying to use the xmlrpc api in magento 1.9 to add a list of products to the shop. I've got creating the products working with a lot of tinkering but I cannot add rows to the "Group price" field of the product.

This is the current version of my productCreate function:

public function productCreate(MagentoProduct $product)
{
    $parameters = [
        'simple',
        '4', // attribute set
        $product->sku,
        [
            'website_ids' => [2, 3, 4, 7],
            'category_ids' => [7],
            'name' => $product->name,
            'description' => $product->description,
            'short_description' => $product->short_description,
            'weight' => $product->weight,
            'url_key' => $product->url_key,
            'url_path' => $product->url_path,
            'price' => $product->price,
            'tax_class_id' => $product->tax_class_id,
            'meta_title' => $product->meta_title,
            'meta_keyword' => $product->meta_keyword,
            'meta_description' => $product->meta_description,
            'status' => 1,
            'group_price' => [
                'website_id' => 1,
                'cust_group' => 2,
                'price' => '100.0',
            ],
        ]
    ];
    return $this->client->call('product.create', $parameters);
}

I've tried using tier price with qty of 0 or 1 but those are saved to the wrong table. If I retrieve some existing products through the xmlrpc api then I do get the group prices in the tier price list without any quantity but creating them that way doesn't work.

In the function above I'm setting the values in the (undocumented) group_price field. The error I'm getting now is:

'fXmlRpc\Exception\ResponseException' with message 'Dubbele website groep prijs klantengroep.'

which translates to:

Duplicate website group price customer group.

Does anybody know the correct way of setting the group price?

Upvotes: 1

Views: 845

Answers (1)

Puresoft
Puresoft

Reputation: 83

It looks like magento does not support group price updates within their api.

You have to create your own api for this.

Read this: https://magento.stackexchange.com/questions/56481/use-api-v2-to-work-with-customer-group-prices

and this

How to update group price via SOAP api

Upvotes: 1

Related Questions