Skip to content

Commit

Permalink
Merge pull request #2 from justuno-com/master
Browse files Browse the repository at this point in the history
added finalprice function and changed datetime to utc
  • Loading branch information
socks415 authored Mar 24, 2021
2 parents cb92c62 + 3875f3e commit 50fcb5f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 39 deletions.
37 changes: 17 additions & 20 deletions app/code/community/Justuno/M1/Catalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,25 +71,21 @@ static function p() {R::p(function(S $s) {
# «The parent ID is pulling the sku, it should be pulling the ID like the variant does»:
# https://github.com/justuno-com/m1/issues/19
,'ID' => $p->getId()
/**
* 2019-10-30
* 1) «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
* or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
* 2) «If their isn't an MSRP for some reason just use the salesprice»:
* https://github.com/justuno-com/m1/issues/6
* 2019-10-31
* «The MSRP should pull in this order MSRP > Price > Dynamic Price»:
* https://github.com/justuno-com/m1/issues/20
*/
,'MSRP' => (float)($p['msrp'] ?: ($p['price'] ?: $p->getPrice()))
/**
* 2019-10-30
* «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
* or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
* 2019-10-31
* «Price should be Price > Dynamic Price»: https://github.com/justuno-com/m1/issues/21
*/
,'Price' => (float)($p['price'] ?: $p->getPrice())
# 2019-10-30
# 1) «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
# or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
# 2) «If their isn't an MSRP for some reason just use the salesprice»:
# https://github.com/justuno-com/m1/issues/6
# 2019-10-31
# «The MSRP should pull in this order MSRP > Price > Dynamic Price»: https://github.com/justuno-com/m1/issues/20
# 2021-03-24 "Replace `getPrice` with `getFinalPrice`": https://github.com/justuno-com/m1/issues/54
,'MSRP' => (float)($p['msrp'] ?: ($p['price'] ?: $p->getFinalPrice()))
# 2019-10-30
# «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
# or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
# 2019-10-31 «Price should be Price > Dynamic Price»: https://github.com/justuno-com/m1/issues/21
# 2021-03-24 "Replace `getPrice` with `getFinalPrice`": https://github.com/justuno-com/m1/issues/54
,'Price' => (float)($p['price'] ?: $p->getFinalPrice())
# 2019-10-30 «ReviewsCount and ReviewSums need to be Ints»: https://github.com/justuno-com/m1/issues/11
,'ReviewsCount' => (int)$rs->getReviewsCount()
# 2019-10-30
Expand All @@ -100,7 +96,8 @@ static function p() {R::p(function(S $s) {
# 2019-10-30
# «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
# or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
,'SalePrice' => (float)$p->getPrice()
# 2021-03-24 "Replace `getPrice` with `getFinalPrice`": https://github.com/justuno-com/m1/issues/54
,'SalePrice' => (float)$p->getFinalPrice()
,'Tags' => self::tags($p)
,'Title' => $p['name']
,'UpdatedAt' => $p['updated_at']
Expand Down
29 changes: 14 additions & 15 deletions app/code/community/Justuno/M1/Catalog/Variants.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,23 @@ private static function variant(P $p, P $parent = null, $opts = []) {
* https://github.com/justuno-com/m1/issues/35
*/
,'InventoryQuantity' => $p->isDisabled() || ($parent && $parent->isDisabled()) ? -9999 : (int)$si->getQty()
/**
* 2019-10-30
* 1) «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
* or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
* 2) «MSRP was null for some variants but the MSRP wasn't null for the parent»:
* https://github.com/justuno-com/m1/issues/7
* 3) «If their isn't an MSRP for some reason just use the salesprice»:
* https://github.com/justuno-com/m1/issues/6
* 2019-10-31
* «For variant pricing,
* i would want the flow to be the same as the MSRP and SalePrice from the parent above
* but using the variant's pricing of course»: https://github.com/justuno-com/m1/issues/25
*/
,'MSRP' => (float)($p['msrp'] ?: ($p['price'] ?: $p->getPrice()))
# 2019-10-30
# 1) «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
# or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
# 2) «MSRP was null for some variants but the MSRP wasn't null for the parent»:
# https://github.com/justuno-com/m1/issues/7
# 3) «If their isn't an MSRP for some reason just use the salesprice»: https://github.com/justuno-com/m1/issues/6
# 2019-10-31
# «For variant pricing,
# i would want the flow to be the same as the MSRP and SalePrice from the parent above
# but using the variant's pricing of course»: https://github.com/justuno-com/m1/issues/25
# 2021-03-24 "Replace `getPrice` with `getFinalPrice`": https://github.com/justuno-com/m1/issues/54
,'MSRP' => (float)($p['msrp'] ?: ($p['price'] ?: $p->getFinalPrice()))
# 2019-10-30
# «MSRP, Price, SalePrice, Variants.MSRP, and Variants.SalePrice all need to be Floats,
# or if that is not possible then Ints»: https://github.com/justuno-com/m1/issues/10
,'SalePrice' => (float)$p->getPrice()
# 2021-03-24 "Replace `getPrice` with `getFinalPrice`": https://github.com/justuno-com/m1/issues/54
,'SalePrice' => (float)$p->getFinalPrice()
,'SKU' => $p->getSku()
,'Title' => $p->getName()
];
Expand Down
8 changes: 5 additions & 3 deletions app/code/community/Justuno/M1/Filter.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php
use DateTimeZone as TZ;
use Justuno_M1_Lib as L;
use Mage_Catalog_Model_Resource_Product_Collection as PC;
use Mage_Sales_Model_Resource_Order_Collection as OC;
Expand Down Expand Up @@ -35,15 +36,16 @@ static function p(C $r) {
*/
private static function byDate(C $c) {
if ($since = L::req('updatedSince')) { /** @var string $since */
# 2021-03-24 "`updatedSince` should be interpreted in the UTC timezone": https://github.com/justuno-com/m1/issues/55
$tz = new TZ(TZ::UTC); /** @var TZ $tz */
/**
* 2019-10-31
* @param string $s
* @return string
*/
$d = function($s) {
$d = function($s) use($tz) {
$f = 'Y-m-d H:i:s'; /** @var string $f */
$tz = Mage::getStoreConfig('general/locale/timezone'); /** @var string $tz */
$dt = new DateTime(date($f, strtotime($s)), new DateTimeZone($tz)); /** @var DateTime $dt */
$dt = new DateTime(date($f, strtotime($s)), $tz); /** @var DateTime $dt */
return date($f, $dt->format('U'));
};
$c->addFieldToFilter('updated_at', ['from' => $d($since), 'to' => $d('2035-01-01 23:59:59')]);
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Justuno/M1/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<Justuno_M1>
<author>Dmitry Fedyuk</author>
<url>https://www.upwork.com/fl/mage2pro</url>
<version>1.6.6</version>
<version>1.6.8</version>
</Justuno_M1>
</modules>
<frontend>
Expand Down

0 comments on commit 50fcb5f

Please sign in to comment.