header

Magento 1.x Software Support Notice

For Magento Commerce 1, Magento is providing software support through June 2020. Depending on your Magento Commerce 1 version, software support may include both quality fixes and security patches. Please review our Magento Software Lifecycle Policy to see how your version of Magento Commerce 1 is supported.

For Magento Open Source 1.5 to 1.9, Magento is providing software security patches through June 2020 to ensure those sites remain secure and compliant. Visit our information page for more details about our software maintenance policy and other considerations for your business.

Product Websites

REST API: Product Websites

URI: /products/:product_id/websites

Allows you to retrieve information about websites assigned to a product, assign a website to a product, and copy data for a product from a specified store view.

URL Structure: http://magentohost/api/rest/products/:product_id/websites
Version: 1

HTTP Method: GET

Description: Allows you to retrieve information about websites assigned to the specified product.

Authentication: Admin
Default Format: XML
Parameters:
No Parameters

Example:

GET http://magentohost/api/rest/products/8/websites

Response Body:

<?xml version="1.0"?>
<magento_api>
  <data_item>
    <website_id>2</website_id>
  </data_item>
</magento_api>
HTTP Method: POST
Website Assignment

Description: Allows you to assign a website to a specified product.

Authentication: Admin
Default Format: XML
Parameters:

Name Description Required Type Example Value
website_id The website ID required int 2

Example:

POST http://magentohost/api/rest/products/8/websites

Request Body:

<?xml version="1.0"?>
<magento_api>
    <website_id>1</website_id>
</magento_api>

Response Body:

<?xml version="1.0"?>
<magento_api>
  <success>
    <data_item>
      <website_id>1</website_id>
      <product_id>8</product_id>
      <message>Resource updated successful.</message>
      <code>200</code>
    </data_item>
  </success>
</magento_api>



Website Assignment with Product Data Copying

Description: Allows you to assign a website and copy product data from the attached store to the one being attached. Only product data that is set on the Store View level is copied. All other data set on the Website or Global levels is not copied.

Authentication: Admin
Default Format: XML
Parameters:

Name Description Required Type Example Value
website_id The website ID required int 2
store_from The store ID from which data will be copied required int 1
store_to The store ID to which data will be copied required int 2

Notes: The store_to parameter must belong to the website which we want to assign to a product.

Example:

POST http://magentohost/api/rest/products/8/websites

Request Body:

<?xml version="1.0"?>
<magento_api>
     <website_id>2</website_id>
      <copy_to_stores>
          <data_item>
               <store_from>1</store_from>
               <store_to>2</store_to>
           </data_item>
      </copy_to_stores>
</magento_api>



Multi-Website Assignment

Description: Allows you to assign multiple websites to a product.

Authentication: Admin
Default Format: XML
Parameters:

Name Description Required Type Example Value
website_id The website ID required int 2

Example:

POST http://magentohost/api/rest/products/8/websites

Request Body:

<?xml version="1.0"?>
<magento_api>
  <data_item>
    <website_id>1</website_id>
  </data_item>
  <data_item>
    <website_id>3</website_id>
  </data_item>
</magento_api>

Response Body:

<?xml version="1.0"?>
<magento_api>
  <success>
    <data_item>
      <website_id>1</website_id>
      <product_id>8</product_id>
      <message>Resource updated successful.</message>
      <code>200</code>
    </data_item>
    <data_item>
      <website_id>3</website_id>
      <product_id>8</product_id>
      <message>Resource updated successful.</message>
      <code>200</code>
    </data_item>
  </success>
</magento_api>



Multi-Website Assignment with Product Data Copying

Description: Allows you to assign multiple websites to a product together with copying product data from the attached store to the one being attached. Only product data that is set on the Store View level is copied. All other data set on the Website or Global levels is not copied.

Authentication: Admin
Default Format: XML
Parameters:

Name Description Required Type Example Value
website_id The website ID required int 2
store_from The store ID from which data will be copied required int 1
store_to The store ID to which data will be copied required int 2

Example:

POST http://magentohost/api/rest/products/8/websites

Request Body:

<?xml version="1.0"?>
<magento_api>
    <data_item>
        <website_id>2</website_id>
        <copy_to_stores>
            <data_item>
                <store_from>1</store_from>
                <store_to>2</store_to>
            </data_item>
        </copy_to_stores>
    </data_item>
    <data_item>
        <website_id>3</website_id>
        <copy_to_stores>
            <data_item>
                <store_from>1</store_from>
                <store_to>5</store_to>
            </data_item>
        </copy_to_stores>
    </data_item>
</magento_api>

Response Body:

<?xml version="1.0"?>
<magento_api>
  <success>
    <data_item>
      <website_id>2</website_id>
      <product_id>8</product_id>
      <message>Resource updated successful.</message>
      <code>200</code>
    </data_item>
    <data_item>
      <website_id>3</website_id>
      <product_id>8</product_id>
      <message>Resource updated successful.</message>
      <code>200</code>
    </data_item>
  </success>
</magento_api>



URI: /products/:product_id/websites/:website_id

Allows you to unassign a website from a specified product.

URL Structure: http://magentohost/api/rest/products/:product_id/websites/:website_id
Version: 1

HTTP Method: DELETE

Description: Allows you to unassign a website from a specified product.

Authentication: Admin
Default Format: XML
Parameters:
No Parameters

Example:

DELETE http://magentohost/api/rest/products/8/websites/1

Possible HTTP Status Codes

Status Code Message Description
404 Product not found The specified product is not found or does not exist.
404 Website not found The specified website is not found or does not exist.
400 Invalid value for "store_from" for the website with ID <ID value>. The entered value for "store_from" is not valid.
400 Invalid value for "store_to" for the website with ID <ID value>.
The entered value for "store_to" is not valid.
400 Store not found <store ID> for website <website ID>. The specified store is not found or does not exist.
400 Store <store ID> from which we will copy the information does not belong to the product <product ID> being edited. The specified store is not assigned to the product.
400 Store <store ID> to which we will copy the information does not belong to the website <website ID> being added. The specified store does not belong to the website.
400 Product <product ID> isn't assigned to website <website ID>. The specified product is not assigned to the website.
400 Invalid value for "website_id" in request. The value for "website_id" is not valid.