Question

Is there any way to removing sale prices in different stores? using any script ? or using any other way except admin?

I'm using five different stores, default store is easy but other multi stores take ages as you can only change simple products manually and it looks like you can’t change the configurable products.

Basically, it takes about 20 minutes to take a shoe off sale which can’t be right.

Was it helpful?

Solution

Price is set at simple product level in Magento 2 (and configurable products will inherit the special price from simple products beneath it).

The quickest way to do it correctly would be to use the REST API inside a script. This is the best way if you're a beginner - Magento has created this as an interface for external integration which should be used wherever possible.

http://devdocs.magento.com/swagger/index_20.html#!/catalogProductRepositoryV1

The correct endpoint is catalogProductRepository's PUT /V1/products/{sku} -

Note that you need to put the storeview code into the calling URL as described here.

http://devdocs.magento.com/guides/v2.0/rest/rest_endpoints.html

Here is a good post on using a script with the REST API

GET or SET Product special price using REST API

Another option is to import a multi store CSV using Magento 2 import functionality - this is best if you're not familiar with Magento/PHP development:

Here is an article about it:

https://www.alexcorradi.org/blog/a-guide-on-how-to-import-export-products-in-magento-2

Otherwise if you have a test environment and are more confident with coding you can create your own script to update:

Inside a class you'd have:

protected $action;

public function __construct(\Magento\Catalog\Model\Product\Action $productAction) {
   $this->action = $productAction;
}

public function updatePrice($productIds, $data, $storeId) {
    $this->action->updateAttributes($productIds, $data, $storeId);
}

then to run it use the following;

 $specialPrice = null; // OR '' can't remember off the top of my head which clears it - perhaps either.

 $data = ['special_price' => $specialPrice];
 $storeId = 1; //whatever store id you like
 $productIds = [1,2,3,4,5,6,7]; //whatever product ids you wish to change.

 $this->updatePrice($productIds, $data, $storeId);

run for each store.

Apologies for any mistakes, I am just typing by memory. Please run on a test environment first!

OTHER TIPS

Try1: You can use plugin approch for update sell price.

Try2: You can remove sell_price from default attribute set or disable this attribute so without any effort you can do this.

Use catalog price rules. Marketing > Catalog Price Rules

This way, you can set the sale prices by all stores or select stores and it is easy to update and enable or disable en mass.

You can set the conditions to match all manner of combinations: category/manufacturer/size/color/sku/mpn

You can also create attributes in the backend that you can use for catalog price rules. eg. I have an attribute 'season' with drop down options like 2017-4, which is winter products.

So I make a catalog price rule for: Manufacturer = Billabong, Category = Shirts, Season = 2017-4 and apply 20% off to products matching those criteria. And you can set the websites where the rule is applied, as well as the dates you want the rules to run.

You can also use color or sizes in your rules. This becomes very advantageous when the product hasn't changed names for a few years and there's an old colorway that you want to get rid of, you can set only the one color and or size combination to be on sale, while the rest of the configurable products stay the regular price.

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top