4

I have an import script which imports configs and the variants.

There is set the special price if some is set in my import XML document. If no special price is set, i try to remove the special price. - But it do not work! - The special price is already set, after save!

if ($oProductGroupVariantProductItem->getSpecialpriceBrutto() > 0) {
    $oSimpleProduct->setSpecialPrice($oProductGroupVariantProductItem->getSpecialpriceBrutto());
} else {
    $oSimpleProduct->setSpecialPrice('');
}

what i am doing wrong?

Thanks Andre

  • try with unset($oProductGroupVariantProductItem->getSpecialpriceBrutto()) – Rakesh Jesadiya Jan 20 '17 at 13:06
  • ??? - I want to unset the "$oSimpleProduct" special price value !! Not my Import Data Value Object! – Andre Bubner Jan 20 '17 at 13:10
  • you can do this in else case of your condition – Rakesh Jesadiya Jan 20 '17 at 13:10
  • Any luck with this? – Martin Wickman Feb 21 '17 at 9:32
7

Saving the price and forcibly update the product attribute using the resource model worked in my situtation:

$product->setSpecialPrice(null);
$product->getResource()->saveAttribute($product, 'special_price');
1

You just need to save the product after you updated the attributes.

Try this:

$oSimpleProduct->save();
  • Don't use deprecated save()-methods on legacy models. Use the repository instead (see ProductRepositoryInterface::save()). – Giel Berkers May 17 '17 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.