Skip to content

Instantly share code, notes, and snippets.

@peterjaap
Last active February 19, 2023 10:48
Show Gist options
  • Save peterjaap/fe61f7a454c8f3610ee7 to your computer and use it in GitHub Desktop.
Save peterjaap/fe61f7a454c8f3610ee7 to your computer and use it in GitHub Desktop.
Wyomind Data Feed Manager conditional special price - this custom attribute for Wyomind Data Feed Manager only shows the special price when the special price is set lower than the original price.
<?php
if($product->getSpecialPrice() && $product->getSpecialPrice() > 0 && $product->getSpecialPrice() < $product->getPrice()) {
$specialPriceInclTax = Mage::helper('tax')->getPrice($product, $product->getSpecialPrice(), true);
$conditionalSpecialPrice = '<g:sale_price>' . $specialPriceInclTax . '</g:sale_price>' . PHP_EOL;
$specialFromDate = $product->getSpecialFromDate();
$specialToDate = $product->getSpecialToDate();
if($specialFromDate && !$specialToDate) {
$specialToDate = '2100-01-01';
}
if($specialToDate && !$specialFromDate) {
$specialFromDate = '1970-01-01';
}
if($specialFromDate && $specialToDate) {
$specialFromDate = date('c', strtotime($specialFromDate));
$specialToDate = date('c', strtotime($specialToDate));
$conditionalSpecialPrice .= '<g:sale_price_effective_date>' . $specialFromDate . '/' . $specialToDate . '</g:sale_price_effective_date>';
}
} else {
$conditionalSpecialPrice = null;
}
return $conditionalSpecialPrice;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment