From b4e7fdf26005d4d8ee3608022e5c32b9964fa7bd Mon Sep 17 00:00:00 2001 From: Dmitriy Belousov Date: Mon, 28 Nov 2016 14:34:22 +0200 Subject: [PATCH] 6.4.7 RELEASE FINAL --- .../Common/Amazon/Account/Edit/Tabs.php | 2 +- .../Amazon/Account/Edit/Tabs/Repricing.php | 22 +- .../Amazon/Grid/Column/Filter/Price.php | 2 +- .../Common/Amazon/Listing/Other/View.php | 4 + .../Common/Amazon/Listing/Other/View/Grid.php | 35 +- .../Common/Amazon/Listing/Search/Grid.php | 125 +++- .../Product/Manage/Tabs/Variations/Grid.php | 120 +++- .../Adminhtml/Common/Amazon/Listing/View.php | 4 + .../Amazon/Listing/View/Amazon/Grid.php | 119 +++- .../Listing/View/Sellercentral/Grid.php | 61 +- app/code/community/Ess/M2ePro/CHANGELOG | 11 + .../Ess/M2ePro/Helper/Component/Amazon.php | 5 - .../Helper/Component/Amazon/Repricing.php | 110 +++ .../community/Ess/M2ePro/Helper/Module.php | 2 +- .../Helper/Module/Database/Structure.php | 2 + .../Ess/M2ePro/Helper/Module/License.php | 37 + .../Ess/M2ePro/Model/Amazon/Account.php | 74 +- .../M2ePro/Model/Amazon/Account/Repricing.php | 571 ++++++++++++++++ .../Ess/M2ePro/Model/Amazon/Listing.php | 12 + .../Ess/M2ePro/Model/Amazon/Listing/Other.php | 18 + .../Model/Amazon/Listing/Other/Moving.php | 11 + .../M2ePro/Model/Amazon/Listing/Product.php | 69 +- .../Listing/Product/Action/Type/Validator.php | 5 +- .../Listing/Product/PriceCalculator.php | 14 + .../Amazon/Listing/Product/Repricing.php | 337 ++++++++++ .../Product/Repricing/PriceCalculator.php | 73 ++ .../Amazon/Listing/Product/Variation.php | 3 + .../Relation/Parent/Processor/Sub/Selling.php | 30 +- .../Ess/M2ePro/Model/Amazon/Repricing.php | 635 ------------------ .../Model/Amazon/Repricing/Abstract.php | 57 ++ .../Model/Amazon/Repricing/Action/Account.php | 77 +++ .../Model/Amazon/Repricing/Action/Product.php | 203 ++++++ .../Repricing/Synchronization/Abstract.php | 54 ++ .../Repricing/Synchronization/ActualPrice.php | 170 +++++ .../Repricing/Synchronization/General.php | 620 +++++++++++++++++ .../Model/Amazon/Repricing/Updating.php | 86 +++ .../Model/Amazon/Synchronization/Defaults.php | 1 - .../Defaults/UpdateRepricing.php | 126 ---- .../Amazon/Synchronization/Orders/Update.php | 14 +- .../Amazon/Synchronization/Templates.php | 1 + .../Synchronization/Templates/Inspector.php | 4 +- .../Synchronization/Templates/Repricing.php | 162 +++++ .../Buy/Listing/Product/PriceCalculator.php | 14 + .../Model/Buy/Listing/Product/Variation.php | 1 + .../Amazon/Orders/Get/ItemsResponser.php | 9 +- .../M2ePro/Model/Cron/Strategy/Abstract.php | 4 + .../M2ePro/Model/Cron/Strategy/Parallel.php | 4 + .../Cron/Task/RepricingInspectProducts.php | 132 ++++ .../RepricingSynchronizationActualPrice.php | 63 ++ .../Task/RepricingSynchronizationGeneral.php | 63 ++ .../Cron/Task/RepricingUpdateSettings.php | 140 ++++ .../Ebay/Listing/Product/PriceCalculator.php | 14 + .../Model/Ebay/Listing/Product/Variation.php | 1 + .../Model/Listing/Product/PriceCalculator.php | 39 +- .../Model/Mysql4/Amazon/Account/Repricing.php | 64 ++ .../Amazon/Account/Repricing/Collection.php | 21 + .../Model/Mysql4/Amazon/Listing/Other.php | 47 ++ .../Model/Mysql4/Amazon/Listing/Product.php | 33 + .../Amazon/Listing/Product/Repricing.php | 81 +++ .../Listing/Product/Repricing/Collection.php | 21 + .../Amazon/Account/RepricingController.php | 162 +++-- .../Common/Amazon/AccountController.php | 18 + .../Amazon/Listing/RepricingController.php | 302 ++++++--- app/code/community/Ess/M2ePro/etc/config.xml | 9 +- ...all-6.4.6.php => mysql4-install-6.4.7.php} | 103 ++- .../mysql4-upgrade-6.4.6.1-6.4.7.php | 255 +++++++ .../common/amazon/account/tabs/general.phtml | 5 +- .../amazon/account/tabs/repricing.phtml | 427 +++++++++++- composer.json | 4 +- js/M2ePro/Common/Amazon/AccountHandler.js | 194 +++++- .../Common/Amazon/Listing/RepricingHandler.js | 28 +- .../default/default/M2ePro/images/money.png | Bin 1721 -> 941 bytes .../default/M2ePro/images/money_disabled.png | Bin 0 -> 1206 bytes .../default/M2ePro/images/money_mixed.png | Bin 0 -> 682 bytes .../M2ePro/images/money_disabled.png | Bin 0 -> 1206 bytes .../enterprise/M2ePro/images/money_mixed.png | Bin 0 -> 682 bytes 76 files changed, 5177 insertions(+), 1169 deletions(-) create mode 100644 app/code/community/Ess/M2ePro/Helper/Component/Amazon/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Account/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product/Repricing/PriceCalculator.php delete mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Abstract.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Action/Account.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Action/Product.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Synchronization/Abstract.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Synchronization/ActualPrice.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Synchronization/General.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Repricing/Updating.php delete mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Synchronization/Defaults/UpdateRepricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Amazon/Synchronization/Templates/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Cron/Task/RepricingInspectProducts.php create mode 100644 app/code/community/Ess/M2ePro/Model/Cron/Task/RepricingSynchronizationActualPrice.php create mode 100644 app/code/community/Ess/M2ePro/Model/Cron/Task/RepricingSynchronizationGeneral.php create mode 100644 app/code/community/Ess/M2ePro/Model/Cron/Task/RepricingUpdateSettings.php create mode 100644 app/code/community/Ess/M2ePro/Model/Mysql4/Amazon/Account/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Mysql4/Amazon/Account/Repricing/Collection.php create mode 100644 app/code/community/Ess/M2ePro/Model/Mysql4/Amazon/Listing/Product/Repricing.php create mode 100644 app/code/community/Ess/M2ePro/Model/Mysql4/Amazon/Listing/Product/Repricing/Collection.php rename app/code/community/Ess/M2ePro/sql/M2ePro_setup/{mysql4-install-6.4.6.php => mysql4-install-6.4.7.php} (96%) create mode 100644 app/code/community/Ess/M2ePro/sql/M2ePro_setup/mysql4-upgrade-6.4.6.1-6.4.7.php create mode 100644 skin/adminhtml/default/default/M2ePro/images/money_disabled.png create mode 100644 skin/adminhtml/default/default/M2ePro/images/money_mixed.png create mode 100644 skin/adminhtml/default/enterprise/M2ePro/images/money_disabled.png create mode 100644 skin/adminhtml/default/enterprise/M2ePro/images/money_mixed.png diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php index 42a7a0271..dcd26e746 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs.php @@ -46,7 +46,7 @@ protected function _beforeToHtml() ->createBlock('M2ePro/adminhtml_common_amazon_account_edit_tabs_order')->toHtml(), )); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && Mage::helper('M2ePro/Data_Global')->getValue('temp_data')->getId()) { $this->addTab('repricing', array( diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Repricing.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Repricing.php index 0c784dce4..b2368838c 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Repricing.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Account/Edit/Tabs/Repricing.php @@ -8,6 +8,14 @@ class Ess_M2ePro_Block_Adminhtml_Common_Amazon_Account_Edit_Tabs_Repricing extends Mage_Adminhtml_Block_Widget { + public $isRepricingLinked; + public $m2eProRepricingProducts; + + /** + * @var Ess_M2ePro_Model_Amazon_Account_Repricing + */ + public $repricingObj; + //######################################## public function __construct() @@ -32,23 +40,25 @@ protected function _beforeToHtml() /** @var $accountObj Ess_M2ePro_Model_Account */ $accountObj = Mage::helper('M2ePro/Data_Global')->getValue('temp_data'); - $this->isRepricingLinked = $accountObj->getChildObject()->isRepricingLinked(); + $this->isRepricingLinked = $accountObj->getChildObject()->isRepricing(); if ($this->isRepricingLinked) { - $this->repricingData = $accountObj->getChildObject()->getRepricing(); + $this->repricingObj = $accountObj->getChildObject()->getRepricing(); /** @var Ess_M2ePro_Model_Mysql4_Amazon_Listing_Product_Collection $collection */ $collection = Mage::helper('M2ePro/Component_Amazon')->getCollection('Listing_Product'); - $collection->getSelect() - ->join(array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()), - '(`l`.`id` = `main_table`.`listing_id`)', array()); + $collection->getSelect()->join( + array('l' => Mage::getResourceModel('M2ePro/Listing')->getMainTable()), + '(`l`.`id` = `main_table`.`listing_id`)', + array() + ); $collection->getSelect()->where("`second_table`.`is_variation_parent` = 0"); $collection->getSelect()->where("`second_table`.`is_repricing` = 1"); $collection->getSelect()->where("`l`.`account_id` = ?", $accountObj->getId()); - $this->m2eproRepricingProducts = $collection->count(); + $this->m2eProRepricingProducts = $collection->count(); } } diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Grid/Column/Filter/Price.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Grid/Column/Filter/Price.php index 1e98c4600..2f7f2fc56 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Grid/Column/Filter/Price.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Grid/Column/Filter/Price.php @@ -17,7 +17,7 @@ public function getHtml() return parent::getHtml() . '
'. - Mage::helper('M2ePro')->__('Repricing ON') . ': ' . + Mage::helper('M2ePro')->__('Repricing') . ': ' . '
'; } diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View.php index 5ee94fce0..df5a75e02 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View.php @@ -99,6 +99,9 @@ protected function _toHtml() $unmappingProductsUrl = $this->getUrl('*/adminhtml_listing_other_mapping/unmapping'); $getAFNQtyBySku = $this->getUrl('*/adminhtml_common_amazon_listing/getAFNQtyBySku'); + $getUpdatedRepricingPriceBySkus = $this->getUrl( + '*/adminhtml_common_amazon_listing_repricing/getUpdatedPriceBySkus' + ); $someProductsWereNotMappedMessage = 'No matches were found. Please change the Mapping Attributes in '; $someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings '; @@ -203,6 +206,7 @@ protected function _toHtml() M2eProAmazon.url.unmappingProducts = '{$unmappingProductsUrl}'; M2ePro.url.getAFNQtyBySku = '{$getAFNQtyBySku}'; + M2ePro.url.getUpdatedRepricingPriceBySkus = '{$getUpdatedRepricingPriceBySkus}'; M2eProAmazon.text.create_listing = '{$createListing}'; M2eProAmazon.text.popup_title = '{$popupTitle}'; diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View/Grid.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View/Grid.php index 78001d5c0..7bba88647 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View/Grid.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Other/View/Grid.php @@ -123,7 +123,7 @@ protected function _prepareColumns() 'filter_condition_callback' => array($this, 'callbackFilterPrice') ); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled()) { $priceColumn['filter'] = 'M2ePro/adminhtml_common_amazon_grid_column_filter_price'; } @@ -281,7 +281,7 @@ public function callbackColumnProductTitle($value, $row, $column, $isExport) if (is_null($value)) { $value = 'receiving...'; } else { - $value = '' . Mage::helper('M2ePro')->escapeHtml($value) . ''; + $value = '' .Mage::helper('M2ePro')->escapeHtml($value). ''; } $tempSku = $row->getData('sku'); @@ -341,20 +341,33 @@ public function callbackColumnAvailableQty($value, $row, $column, $isExport) public function callbackColumnPrice($value, $row, $column, $isExport) { - $html =''; + $html = ''; - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && - (int)$row->getData('is_repricing') === Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && + (int)$row->getData('is_repricing') == 1) { + + $image = 'money'; $text = Mage::helper('M2ePro')->__( - 'This product is used by Amazon Repricing Tool. - The Price cannot be updated through the M2E Pro.' + 'This Product is used by Amazon Repricing Tool, so its Price cannot be managed via M2E Pro.
+ Please note that the Price value(s) shown in the grid might + be different from the actual one from Amazon. It is caused by the delay + in the values updating made via the Repricing Service' ); + if ((int)$row->getData('is_repricing_disabled') == 1) { + $image = 'money_disabled'; + $text = Mage::helper('M2ePro')->__( + 'This product is disabled on Amazon Repricing Tool.
+ You can map it to Magento Product and Move into M2E Pro Listing to make the + Price being updated via M2E Pro.' + ); + } + $html = << +  + src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}"> HTML; + } } $onlineMinPrice = $row->getData('min_online_price'); @@ -736,7 +815,7 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $marketplaceId = $row->getData('marketplace_id'); $currency = Mage::helper('M2ePro/Component_Amazon') - ->getCachedObject('Marketplace',$marketplaceId) + ->getCachedObject('Marketplace', $marketplaceId) ->getChildObject() ->getDefaultCurrency(); @@ -758,7 +837,7 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $resultHtml = ''; $salePrice = $row->getData('online_sale_price'); - if (!$row->getData('is_variation_parent') && (float)$salePrice > 0) { + if (!$row->getData('is_variation_parent') && (float)$salePrice > 0 && !$row->getData('is_repricing')) { $currentTimestamp = strtotime(Mage::helper('M2ePro')->getCurrentGmtDate(false,'Y-m-d 00:00:00')); $startDateTimestamp = strtotime($row->getData('online_sale_price_start_date')); @@ -1009,7 +1088,7 @@ protected function callbackFilterPrice($collection, $column) } - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && !empty($value['is_repricing'])) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && !empty($value['is_repricing'])) { if (!empty($condition)) { $condition = '(' . $condition . ') OR '; } diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php index 18974e4e4..1fb630cff 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/Variation/Product/Manage/Tabs/Variations/Grid.php @@ -95,6 +95,15 @@ protected function _prepareCollection() ) ); + $collection->getSelect()->joinLeft( + array('malpr' => Mage::getResourceModel('M2ePro/Amazon_Listing_Product_Repricing')->getMainTable()), + '(`second_table`.`listing_product_id` = `malpr`.`listing_product_id`)', + array( + 'is_repricing' => 'listing_product_id', + 'is_repricing_disabled' => 'is_online_disabled', + ) + ); + // Set collection to grid $this->setCollection($collection); @@ -175,7 +184,7 @@ protected function _prepareColumns() 'filter_condition_callback' => array($this, 'callbackFilterQty') )); - $this->addColumn('online_price', array( + $priceColumn = array( 'header' => Mage::helper('M2ePro')->__('Price'), 'align' => 'right', 'width' => '70px', @@ -184,7 +193,13 @@ protected function _prepareColumns() 'filter_index' => 'online_price', 'frame_callback' => array($this, 'callbackColumnPrice'), 'filter_condition_callback' => array($this, 'callbackFilterPrice') - )); + ); + + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled()) { + $priceColumn['filter'] = 'M2ePro/adminhtml_common_amazon_grid_column_filter_price'; + } + + $this->addColumn('online_price', $priceColumn); $this->addColumn('status', array( 'header' => Mage::helper('M2ePro')->__('Status'), @@ -543,8 +558,42 @@ public function callbackColumnPrice($value, $row, $column, $isExport) return '' . Mage::helper('M2ePro')->__('Not Listed') . ''; } + $repricingHtml =''; + + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && + (bool)(int)$row->getData('is_repricing')) { + + $image = 'money'; + $text = Mage::helper('M2ePro')->__( + 'This Product is used by Amazon Repricing Tool, so its Price cannot be managed via M2E Pro.
+ Please note that the Price value(s) shown in the grid might + be different from the actual one from Amazon. It is caused by the delay + in the values updating made via the Repricing Service' + ); + + if ((int)$row->getData('is_repricing_disabled') == 1) { + $image = 'money_disabled'; + $text = Mage::helper('M2ePro')->__( + 'This product is disabled on Amazon Repricing Tool. + The Price is updated through the M2E Pro.' + ); + } + + $repricingHtml = <<  + + +
+HTML; + } + if (is_null($value) || $value === '') { - return Mage::helper('M2ePro')->__('N/A'); + return Mage::helper('M2ePro')->__('N/A') . $repricingHtml; } $marketplaceId = $this->getListingProduct()->getListing()->getMarketplaceId(); @@ -600,10 +649,11 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $currentTimestamp <= $endDateTimestamp && $salePrice < (float)$value ) { - $resultHtml .= ''.$priceValue.''; + $resultHtml .= ''.$priceValue.'' . + $repricingHtml; $resultHtml .= '
'.$intervalHtml.' '.$salePriceValue; } else { - $resultHtml .= $priceValue; + $resultHtml .= $priceValue . $repricingHtml; $resultHtml .= '
'.$intervalHtml. ''.' '.$salePriceValue.''; } @@ -611,7 +661,7 @@ public function callbackColumnPrice($value, $row, $column, $isExport) } if (empty($resultHtml)) { - $resultHtml = $priceValue; + $resultHtml = $priceValue . $repricingHtml; } return $resultHtml; @@ -801,22 +851,58 @@ protected function callbackFilterPrice($collection, $column) return; } - $from = $value['from']; - $to = $value['to']; + $condition = ''; + + if (isset($value['from']) || isset($value['to'])) { - $collection->getSelect()->where( - '(online_price >= \''.$from.'\' AND online_price <= \''.$to.'\' AND + if (isset($value['from']) && $value['from'] != '') { + $condition = 'online_price >= \''.$value['from'].'\''; + } + if (isset($value['to']) && $value['to'] != '') { + if (isset($value['from']) && $value['from'] != '') { + $condition .= ' AND '; + } + $condition .= 'online_price <= \''.$value['to'].'\''; + } + + $condition = '(' . $condition . ' AND ( + (online_sale_price_start_date IS NULL AND + online_sale_price_end_date IS NULL) OR online_sale_price IS NULL OR - online_sale_price_start_date > NOW() OR - online_sale_price_end_date < NOW() - )) OR (online_sale_price >= \''.$from.'\' AND online_sale_price <= \''.$to.'\' AND + online_sale_price_start_date > CURRENT_DATE() OR + online_sale_price_end_date < CURRENT_DATE() + )) OR ('; + + if (isset($value['from']) && $value['from'] != '') { + $condition .= 'online_sale_price >= \''.$value['from'].'\''; + } + if (isset($value['to']) && $value['to'] != '') { + if (isset($value['from']) && $value['from'] != '') { + $condition .= ' AND '; + } + $condition .= 'online_sale_price <= \''.$value['to'].'\''; + } + + $condition .= ' AND ( + online_sale_price_start_date IS NOT NULL AND + online_sale_price_end_date IS NOT NULL AND online_sale_price IS NOT NULL AND - online_sale_price_start_date < NOW() AND - online_sale_price_end_date > NOW() - ))' - ); + online_sale_price_start_date < CURRENT_DATE() AND + online_sale_price_end_date > CURRENT_DATE() + ))'; + + } + + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && !empty($value['is_repricing'])) { + if (!empty($condition)) { + $condition = '(' . $condition . ') OR '; + } + $condition .= '`malpr`.`listing_product_id` IS NOT NULL'; + } + + $collection->getSelect()->where($condition); } //######################################## diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php index 4b96454ab..bdf63a8d0 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View.php @@ -302,6 +302,9 @@ public function getGridHtml() $switchToMFN = $this->getUrl('*/adminhtml_common_amazon_listing/switchToMFN'); $getAFNQtyBySku = $this->getUrl('*/adminhtml_common_amazon_listing/getAFNQtyBySku'); + $getUpdatedRepricingPriceBySkus = $this->getUrl( + '*/adminhtml_common_amazon_listing_repricing/getUpdatedPriceBySkus' + ); $variationProductManage = $this->getUrl( '*/adminhtml_common_amazon_listing_variation_product_manage/index'); @@ -449,6 +452,7 @@ public function getGridHtml() M2ePro.url.switchToMFN = '{$switchToMFN}'; M2ePro.url.getAFNQtyBySku = '{$getAFNQtyBySku}'; + M2ePro.url.getUpdatedRepricingPriceBySkus = '{$getUpdatedRepricingPriceBySkus}'; M2ePro.url.variationProductManage = '{$variationProductManage}'; M2ePro.url.variationProductSetGeneralIdOwner = '{$variationProductSetGeneralIdOwner}'; diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php index 34cd1f77f..fed0bc8bd 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Amazon/Grid.php @@ -122,10 +122,10 @@ protected function _prepareCollection() )', 'online_sale_price_start_date' => 'online_sale_price_start_date', 'online_sale_price_end_date' => 'online_sale_price_end_date', + 'is_repricing' => 'is_repricing', 'is_afn_channel' => 'is_afn_channel', 'is_general_id_owner' => 'is_general_id_owner', 'is_variation_parent' => 'is_variation_parent', - 'is_repricing' => 'is_repricing', 'defected_messages' => 'defected_messages', 'min_online_price' => 'IF( (`t`.`variation_min_price` IS NULL), @@ -155,6 +155,14 @@ protected function _prepareCollection() '{{table}}.variation_parent_id is NULL' ); + $collection->getSelect()->joinLeft( + array('malpr' => Mage::getResourceModel('M2ePro/Amazon_Listing_Product_Repricing')->getMainTable()), + '(`alp`.`listing_product_id` = `malpr`.`listing_product_id`)', + array( + 'is_repricing_disabled' => 'is_online_disabled', + ) + ); + $collection->getSelect()->joinLeft( new Zend_Db_Expr('( SELECT @@ -276,7 +284,7 @@ protected function _prepareColumns() 'filter_condition_callback' => array($this, 'callbackFilterPrice') ); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled()) { $priceColumn['filter'] = 'M2ePro/adminhtml_common_amazon_grid_column_filter_price'; } @@ -775,33 +783,108 @@ public function callbackColumnPrice($value, $row, $column, $isExport) return '' . Mage::helper('M2ePro')->__('Not Listed') . ''; } + $listingProductId = (int)$row->getData('id'); + $repricingHtml =''; - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && - (int)$row->getData('is_repricing') === Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && $row->getData('is_repricing')) { + if ($row->getData('is_variation_parent')) { + + $additionalData = (array)json_decode($row->getData('additional_data'), true); + + $enabledCount = isset($additionalData['repricing_enabled_count']) + ? $additionalData['repricing_enabled_count'] : null; + + $disabledCount = isset($additionalData['repricing_disabled_count']) + ? $additionalData['repricing_disabled_count'] : null; + + if ($enabledCount && $disabledCount) { + $image = 'money_mixed'; + $text = Mage::helper('M2ePro')->__( + 'This Parent has either Enabled and Disabled for dynamic repricing Child Products.
+ Please note that the Price value(s) shown in the grid might be + different from the actual one from Amazon. It is caused by the delay in the values + updating made via the Repricing Service.' + ); + } elseif ($enabledCount) { + $image = 'money'; + $text = Mage::helper('M2ePro')->__( + 'All Child Products of this Parent are Enabled for dynamic repricing.
+ Please note that the Price value(s) shown in the grid might be different + from the actual one from Amazon. It is caused by the delay in the values updating + made via the Repricing Service.' + ); + } elseif ($disabledCount) { + $image = 'money_disabled'; + $text = Mage::helper('M2ePro')->__('All Child Products of this Parent are Disabled for Repricing.'); + } else { + $image = 'money'; + $text = Mage::helper('M2ePro')->__( + 'Some Child Products of this Parent are managed by the Repricing Service.
+ Please note that the Price value(s) shown in the grid might be + different from the actual one from Amazon. It is caused by the delay in the + values updating made via the Repricing Service.' + ); + } + + $filter = base64_encode('online_price[is_repricing]=1'); + + $productTitle = Mage::helper('M2ePro')->escapeHtml($row->getData('name')); + $vpmt = Mage::helper('M2ePro')->__('Manage Variations of "%s" ', $productTitle); + $vpmt = addslashes($vpmt); + + $generalId = $row->getData('general_id'); + if (!empty($generalId)) { + $vpmt .= '('. $generalId .')'; + } + + $linkTitle = Mage::helper('M2ePro')->__('Show Child Products managed by Amazon Repricing Service.'); + + $repricingHtml = << + +  [show] + +HTML; + } elseif (!$row->getData('is_variation_parent')) { + $image = 'money'; $text = Mage::helper('M2ePro')->__( - 'Some Child Products are used by Amazon Repricing Tool. - The Price cannot be updated through the M2E Pro.' - ); - } else { - $text = Mage::helper('M2ePro')->__( - 'This product is used by Amazon Repricing Tool. - The Price cannot be updated through the M2E Pro.' + 'This Product is used by Amazon Repricing Tool, so its Price cannot be managed via M2E Pro.
+ Please note that the Price value shown in the grid might be different + from the actual one from Amazon. It is caused by the delay in the values + updating made via the Repricing Service.' ); - } - $repricingHtml = << + if ((int)$row->getData('is_repricing_disabled') == 1) { + $image = 'money_disabled'; + $text = Mage::helper('M2ePro')->__( + 'This product is disabled on Amazon Repricing Tool. The Price is updated through the M2E Pro.' + ); + } + + $repricingHtml = <<  + src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}"> HTML; + } } $onlineMinPrice = $row->getData('min_online_price'); @@ -827,8 +910,7 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $onlineMinPriceStr = Mage::app()->getLocale()->currency($currency)->toCurrency($onlineMinPrice); $onlineMaxPriceStr = Mage::app()->getLocale()->currency($currency)->toCurrency($onlineMaxPrice); - return $onlineMinPriceStr . (($onlineMinPrice != $onlineMaxPrice) ? ' - ' . $onlineMaxPriceStr : '') . - $repricingHtml; + return $onlineMinPriceStr.(($onlineMinPrice != $onlineMaxPrice)?' - '.$onlineMaxPriceStr:'').$repricingHtml; } $onlinePrice = $row->getData('online_price'); @@ -1175,10 +1257,11 @@ protected function callbackFilterPrice($collection, $column) } - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && !empty($value['is_repricing'])) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && !empty($value['is_repricing'])) { if (!empty($condition)) { $condition = '(' . $condition . ') OR '; } + $condition .= 'is_repricing = ' . Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES; } diff --git a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php index e1e4c674b..d75ecd480 100644 --- a/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php +++ b/app/code/community/Ess/M2ePro/Block/Adminhtml/Common/Amazon/Listing/View/Sellercentral/Grid.php @@ -120,13 +120,13 @@ protected function _prepareCollection() 'online_sale_price_start_date' => 'online_sale_price_start_date', 'online_sale_price_end_date' => 'online_sale_price_end_date', 'is_afn_channel' => 'is_afn_channel', + 'is_repricing' => 'is_repricing', 'is_general_id_owner' => 'is_general_id_owner', 'is_variation_parent' => 'is_variation_parent', - 'is_repricing' => 'is_repricing', 'variation_child_statuses' => 'variation_child_statuses', 'variation_parent_id' => 'variation_parent_id', 'defected_messages' => 'defected_messages', - 'min_online_price' => 'IF( + 'min_online_price' => 'IF( `alp`.`online_sale_price_start_date` IS NOT NULL AND `alp`.`online_sale_price_end_date` IS NOT NULL AND `alp`.`online_sale_price_start_date` <= CURRENT_DATE() AND @@ -137,6 +137,13 @@ protected function _prepareCollection() ), '{{table}}.is_variation_parent = 0' ); + $collection->getSelect()->joinLeft( + array('malpr' => Mage::getResourceModel('M2ePro/Amazon_Listing_Product_Repricing')->getMainTable()), + '(`alp`.`listing_product_id` = `malpr`.`listing_product_id`)', + array( + 'is_repricing_disabled' => 'is_online_disabled', + ) + ); // --------------------------------------- // Set collection to grid @@ -210,7 +217,7 @@ protected function _prepareColumns() 'filter_condition_callback' => array($this, 'callbackFilterPrice') ); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled()) { $priceColumn['filter'] = 'M2ePro/adminhtml_common_amazon_grid_column_filter_price'; } @@ -264,7 +271,7 @@ protected function _prepareMassaction() 'edit_fulfillment' => Mage::helper('M2ePro')->__('Fulfillment') ); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled()) { $groups['edit_repricing'] = Mage::helper('M2ePro')->__('Repricing Tool'); } @@ -312,7 +319,19 @@ protected function _prepareMassaction() 'confirm' => Mage::helper('M2ePro')->__('Are you sure?') ), 'edit_fulfillment'); - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled()) { + $listingData = Mage::helper('M2ePro/Data_Global')->getValue('temp_data'); + /** @var Ess_M2ePro_Model_Account $account */ + $account = Mage::helper('M2ePro/Component_Amazon')->getObject('Account', $listingData['account_id']); + + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && + $account->getChildObject()->isRepricing()) { + + $this->getMassactionBlock()->addItem('showDetails', array( + 'label' => Mage::helper('M2ePro')->__('Show Details'), + 'url' => '', + 'confirm' => Mage::helper('M2ePro')->__('Are you sure?') + ), 'edit_repricing'); + $this->getMassactionBlock()->addItem('addToRepricing', array( 'label' => Mage::helper('M2ePro')->__('Add Item(s)'), 'url' => '', @@ -330,12 +349,6 @@ protected function _prepareMassaction() 'url' => '', 'confirm' => Mage::helper('M2ePro')->__('Are you sure?') ), 'edit_repricing'); - - $this->getMassactionBlock()->addItem('showDetails', array( - 'label' => Mage::helper('M2ePro')->__('Show Details'), - 'url' => '', - 'confirm' => Mage::helper('M2ePro')->__('Are you sure?') - ), 'edit_repricing'); } // --------------------------------------- @@ -609,18 +622,30 @@ public function callbackColumnPrice($value, $row, $column, $isExport) $repricingHtml =''; - if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() && - (int)$row->getData('is_repricing') === Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES) { + if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && + (bool)(int)$row->getData('is_repricing')) { + + $image = 'money'; $text = Mage::helper('M2ePro')->__( - 'This product is used by Amazon Repricing Tool. - The Price cannot be updated through the M2E Pro.' + 'This Product is used by Amazon Repricing Tool, so its Price cannot be managed via M2E Pro.
+ Please note that the Price value(s) shown in the grid might + be different from the actual one from Amazon. It is caused by the delay + in the values updating made via the Repricing Service' ); + if ((int)$row->getData('is_repricing_disabled') == 1) { + $image = 'money_disabled'; + $text = Mage::helper('M2ePro')->__( + 'This product is disabled on Amazon Repricing Tool. + The Price is updated through the M2E Pro.' + ); + } + $repricingHtml = << +  + src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}">