Last active
February 19, 2023 10:48
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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