Skip to content

Commit

Permalink
6.4.7 RELEASE FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
d-belousov committed Nov 28, 2016
1 parent e5c6a3c commit b4e7fdf
Show file tree
Hide file tree
Showing 76 changed files with 5,177 additions and 1,169 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function getHtml()

return parent::getHtml() .
'<div class="range"><div class="range-line" style="width: auto;"><span class="label" style="width: auto;">'.
Mage::helper('M2ePro')->__('Repricing ON') . ': </span>' .
Mage::helper('M2ePro')->__('Repricing') . ': </span>' .
'<input style="margin-left:6px;float:none;width:auto !important;" type="checkbox" value="1" name="'.
$this->_getHtmlName() . '[is_repricing]" ' . $afnChecked . '></div></div>';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <strong>';
$someProductsWereNotMappedMessage .= 'Configuration > Account > 3rd Party Listings</strong> ';
Expand Down Expand Up @@ -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}';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}

Expand Down Expand Up @@ -281,7 +281,7 @@ public function callbackColumnProductTitle($value, $row, $column, $isExport)
if (is_null($value)) {
$value = '<i style="color:gray;">receiving...</i>';
} else {
$value = '<span>' . Mage::helper('M2ePro')->escapeHtml($value) . '</span>';
$value = '<span>' .Mage::helper('M2ePro')->escapeHtml($value). '</span>';
}

$tempSku = $row->getData('sku');
Expand Down Expand Up @@ -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. <br>
<strong>Please note</strong> 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. <br>
You can map it to Magento Product and Move into M2E Pro Listing to make the
Price being updated via M2E Pro.'
);
}

$html = <<<HTML
<span style="float:right; text-align: left;">
<span style="float:right; text-align: left;">&nbsp;
<img class="tool-tip-image"
style="vertical-align: middle; width: 16px;"
src="{$this->getSkinUrl('M2ePro/images/money.png')}">
src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}">
<span class="tool-tip-message tool-tip-message tip-left" style="display:none;">
<img src="{$this->getSkinUrl('M2ePro/images/i_icon.png')}">
<span>{$text}</span>
Expand Down Expand Up @@ -471,11 +484,11 @@ protected function callbackFilterPrice($collection, $column)
$where .= 'online_price <= ' . $value['to'];
}

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($where)) {
$where = '(' . $where . ') OR ';
}
$where .= 'is_repricing = ' . Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES;
$where .= 'is_repricing = 1';
}

$collection->getSelect()->where($where);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ protected function _prepareCollection()
->join(array('l'=>Mage::getResourceModel('M2ePro/Listing')->getMainTable()),
'(`l`.`id` = `main_table`.`listing_id`)',
array('listing_title'=>'title','store_id','marketplace_id'))
->joinLeft(array('malpr'=>Mage::getResourceModel('M2ePro/Amazon_Listing_Product_Repricing')
->getMainTable()
),
'(`malpr`.`listing_product_id` = `main_table`.`id`)',
array('is_repricing_disabled' => 'is_online_disabled'))
->join(array('al'=>Mage::getResourceModel('M2ePro/Amazon_Listing')->getMainTable()),
'(`al`.`listing_id` = `l`.`id`)',
array('template_selling_format_id'));
Expand Down Expand Up @@ -130,7 +135,9 @@ protected function _prepareCollection()
`second_table`.`online_price`
),
`t`.`variation_max_price`
)'
)',
'additional_data' => 'main_table.additional_data',
'is_repricing_disabled' => 'malpr.is_online_disabled'
)
);
$listingProductCollection->getSelect()->joinLeft(
Expand Down Expand Up @@ -169,7 +176,7 @@ protected function _prepareCollection()
'second_table.listing_product_id=t.variation_parent_id',
array(
'variation_min_price' => 'variation_min_price',
'variation_max_price' => 'variation_max_price',
'variation_max_price' => 'variation_max_price'
)
);

Expand Down Expand Up @@ -209,7 +216,7 @@ protected function _prepareCollection()
'general_id' => 'second_table.general_id',
'is_afn_channel' => 'second_table.is_afn_channel',
'is_variation_parent' => new Zend_Db_Expr('NULL'),
'is_repricing' => 'second_table.is_repricing',
'is_repricing' => 'second_table.is_repricing',
'variation_child_statuses' => new Zend_Db_Expr('NULL'),
'online_sku' => 'second_table.sku',
'online_qty' => 'second_table.online_qty',
Expand All @@ -219,8 +226,10 @@ protected function _prepareCollection()
'online_sale_price_end_date' => new Zend_Db_Expr('NULL'),
'min_online_price' => 'second_table.online_price',
'max_online_price' => 'second_table.online_price',
'additional_data' => new Zend_Db_Expr('NULL'),
'is_repricing_disabled' => 'second_table.is_repricing_disabled',
'variation_min_price' => new Zend_Db_Expr('NULL'),
'variation_max_price' => new Zend_Db_Expr('NULL')
'variation_max_price' => new Zend_Db_Expr('NULL'),
)
);
// ---------------------------------------
Expand All @@ -243,6 +252,7 @@ protected function _prepareCollection()
'is_in_stock',
'product_name',
'listing_title',
'additional_data',
'store_id',
'account_id',
'marketplace_id',
Expand All @@ -266,7 +276,9 @@ protected function _prepareCollection()
'min_online_price',
'max_online_price',
'variation_min_price',
'variation_max_price'
'variation_max_price',
'additional_data',
'is_repricing_disabled'
)
);

Expand Down Expand Up @@ -379,7 +391,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';
}

Expand Down Expand Up @@ -692,33 +704,100 @@ public function callbackColumnPrice($value, $row, $column, $isExport)
return '<span style="color: gray;">' . Mage::helper('M2ePro')->__('Not Listed') . '</span>';
}

$repricingHtml ='';
$repricingHtml = '';

if (Mage::helper('M2ePro/Component_Amazon_Repricing')->isEnabled() && $row->getData('is_repricing')) {

if (Mage::helper('M2ePro/Component_Amazon')->isRepricingEnabled() &&
(int)$row->getData('is_repricing') === Ess_M2ePro_Model_Amazon_Listing_Product::IS_REPRICING_YES) {
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. <br>
<strong>Please note</strong> 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. <br>
<strong>Please note</strong> 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. <br>
<strong>Please note</strong> 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.'
);
}

$repricingHtml = <<<HTML
<br/><span style="float:right; text-align: left;">
<img class="tool-tip-image"
style="vertical-align: middle; width: 16px;"
src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}">
<span class="tool-tip-message tool-tip-message tip-left" style="display:none;">
<img src="{$this->getSkinUrl('M2ePro/images/i_icon.png')}">
<span>{$text}</span>
</span>
</span>
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.<br>
<strong>Please note</strong> 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 = <<<HTML
<span style="float:right; text-align: left;">
if ((int)$row->getData('is_repricing_disabled') == 1) {
$image = 'money_disabled';

if ($this->getId() == 'amazonListingSearchOtherGrid') {
$text = Mage::helper('M2ePro')->__(
'This product is disabled on Amazon Repricing Tool. <br>
You can map it to Magento Product and Move into M2E Pro Listing to make the
Price being updated via M2E Pro.'
);
} else {
$text = Mage::helper('M2ePro')->__(
'This product is disabled on Amazon Repricing Tool.
The Price is updated through the M2E Pro.'
);
}
}

$repricingHtml = <<<HTML
<span style="float:right; text-align: left;">&nbsp;
<img class="tool-tip-image"
style="vertical-align: middle; width: 16px;"
src="{$this->getSkinUrl('M2ePro/images/money.png')}">
src="{$this->getSkinUrl('M2ePro/images/'.$image.'.png')}">
<span class="tool-tip-message tool-tip-message tip-left" style="display:none;">
<img src="{$this->getSkinUrl('M2ePro/images/i_icon.png')}">
<span>{$text}</span>
</span>
</span>
HTML;
}
}

$onlineMinPrice = $row->getData('min_online_price');
Expand All @@ -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();

Expand All @@ -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'));
Expand Down Expand Up @@ -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 ';
}
Expand Down
Loading

0 comments on commit b4e7fdf

Please sign in to comment.