Skip to content

Commit

Permalink
6.4.11 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
d-belousov committed Sep 27, 2017
1 parent a8471d5 commit 24af9c5
Show file tree
Hide file tree
Showing 49 changed files with 1,030 additions and 145 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,21 @@ public function callbackColumnGiftOptions($value, $row, $column, $isExport)

public function callbackColumnRowTotal($value, $row, $column, $isExport)
{
/** @var Ess_M2ePro_Model_Order_Item $row */
/** @var Ess_M2ePro_Model_Amazon_Order_Item $aOrderItem */
$aOrderItem = $row->getChildObject();

$currency = $row->getData('currency');
if (empty($currency)) {
$currency = $this->order->getMarketplace()->getChildObject()->getDefaultCurrency();
}

$price = (float)$row->getData('price') + (float)$row->getData('gift_price');
return Mage::getSingleton('M2ePro/Currency')->formatPrice($currency, $price * $row->getData('qty_purchased'));
$price = $aOrderItem->getPrice() + $aOrderItem->getGiftPrice() + $aOrderItem->getTaxAmount();
$price = $price - $aOrderItem->getDiscountAmount();

return Mage::getSingleton('M2ePro/Currency')->formatPrice(
$currency, $price * $aOrderItem->getQtyPurchased()
);
}

public function getRowUrl($row)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ class Ess_M2ePro_Block_Adminhtml_Ebay_Listing_View_Ebay_Grid
/** @var $sellingFormatTemplate Ess_M2ePro_Model_Ebay_Template_SellingFormat */
private $sellingFormatTemplate = NULL;

private $isTerapeakWidgetEnabled = false;

//########################################

public function __construct()
Expand All @@ -29,10 +27,6 @@ public function __construct()

$this->sellingFormatTemplate = $listing->getChildObject()->getSellingFormatTemplate();
$this->showAdvancedFilterProductsOption = false;

$this->isTerapeakWidgetEnabled = (bool)(int)Mage::helper('M2ePro/Module')->getConfig()->getGroupValue(
'/view/ebay/terapeak/', 'mode'
);
}

//########################################
Expand Down Expand Up @@ -381,10 +375,6 @@ public function callbackColumnTitle($value, $row, $column, $isExport)

$valueHtml = '<span class="product-title-value">' . $title . '</span>';

if (!empty($onlineTitle) && $this->isTerapeakWidgetEnabled) {
$valueHtml .= $this->getTerapeakButtonHtml($row);
}

if (is_null($sku = $row->getData('sku'))) {
$sku = Mage::getModel('M2ePro/Magento_Product')->setProductId($row->getData('entity_id'))->getSku();
}
Expand Down Expand Up @@ -479,39 +469,6 @@ private function getItemFeeHtml($row)

}

private function getTerapeakButtonHtml($row)
{
$buttonTitle = Mage::helper('M2ePro')->__('optimize');
$buttonHtml = <<<HTML
<div class="tp-research" style="">
&nbsp;[<a class="tp-button" target="_blank">{$buttonTitle}</a>]
</div>
HTML;
/* @var $listing Ess_M2ePro_Model_Listing */
$listing = Mage::helper('M2ePro/Data_Global')->getValue('temp_data');

$productId = (int)$row->getData('entity_id');
$storeId = $listing ? (int)$listing['store_id'] : 0;

/** @var $magentoProduct Ess_M2ePro_Model_Magento_Product */
$magentoProduct = Mage::getModel('M2ePro/Magento_Product');
$magentoProduct->setProductId($productId);
$magentoProduct->setStoreId($storeId);

$imageLink = $magentoProduct->getImageLink();

if (empty($imageLink)) {
return $buttonHtml;
}

return $buttonHtml . <<<HTML
<div style="display: none;">
<img class="product-image-value" src="{$imageLink}" />
</div>
HTML;

}

public function callbackColumnEbayItemId($value, $row, $column, $isExport)
{
if ($row->getData('ebay_status') == Ess_M2ePro_Model_Listing_Product::STATUS_NOT_LISTED) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -351,10 +351,11 @@ private function modifyNonUniqueShippingServicesTitles($services)
$ebayId = $category['methods'][$key]['ebay_id'];
$title = $category['methods'][$key]['title'];

$uniqPart = preg_replace('/\w*'.str_replace(' ', '', $title).'/i', '', $ebayId);
$duplicatedPart = str_replace(' ', '', preg_quote($title, '/'));
$uniqPart = preg_replace('/\w*'.$duplicatedPart.'/i', '', $ebayId);
$uniqPart = preg_replace('/([A-Z]+[a-z]*)/', '${1} ', $uniqPart);

$category['methods'][$key]['title'] = trim($title) . ' ' . $uniqPart;
$category['methods'][$key]['title'] = trim($title) . ' ' . str_replace('_', '', $uniqPart);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ public function getChannelFinalFee()
return !$this->getIsSecureMode() ? (float)$this->getAdditionalData('channel_final_fee') : 0;
}

public function getCashOnDeliveryCost()
{
return !$this->getIsSecureMode() ? (float)$this->getAdditionalData('cash_on_delivery_cost') : 0;
}

public function getChannelTitle()
{
$component = $this->getAdditionalData('component_mode');
Expand Down
14 changes: 14 additions & 0 deletions app/code/community/Ess/M2ePro/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
* 6.4.11 (r11702) (27/09/2017)

* Added: Import company name to magento customer during order creation
* Added: [eBay] Ability to receive Waste Recycling Fee from Channel and transfer it to Magento Order
* Added: [eBay] Ability to receiving Cash On Delivery Cost and display it in Order page
* Added: [Amazon] Ability to create Magento order even if it has zero price
* Improvement: Return Products Image URLs based on a store configuration (http / https)
* Improvement: The locking is now based on exclusive MySQL locks (protection of cron to be run in parallel)
* Improvement: [Amazon] Readable error message, about impossible Order Refund, if Credit Memo created without Items (Amazon restriction)
* Fix: [eBay] Watermarks are not being added to the images into custom description
* Fix: [Amazon] Carrier Name of Tracking Number, sent as "DHL (Deprecated)" to Channel in some cases
* Fix: [Amazon] Grand Total value displayed incorrectly in M2E Pro Order page, when VAT on Europe marketplaces presented
* Removed: [eBay] Integration to the the Terapeak service

* 6.4.10 (r11425) (16/05/2017)

* Improvement: [Amazon] Condition Note can be filled only if Condition is different than "New"
Expand Down
14 changes: 14 additions & 0 deletions app/code/community/Ess/M2ePro/Helper/Magento.php
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,18 @@ public function clearCache()
}

//########################################

public function shouldBeSecure($store = NULL, $area = Mage_Core_Model_App_Area::AREA_FRONTEND)
{
if (($area == Mage_Core_Model_App_Area::AREA_FRONTEND && !Mage::app()->getStore($store)->isFrontUrlSecure()) ||
($area == Mage_Core_Model_App_Area::AREA_ADMIN && !Mage::app()->getStore($store)->isAdminUrlSecure()) ||
!Mage::getStoreConfigFlag(Mage_Core_Model_Store::XML_PATH_SECURE_BASE_URL, $store))
{
return false;
}

return true;
}

//########################################
}
2 changes: 1 addition & 1 deletion app/code/community/Ess/M2ePro/Helper/Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function getVersion()

public function getRevision()
{
$revision = '11425';
$revision = '11702';

if ($revision == str_replace('|','#','|REVISION|')) {
$revision = (int)exec('svnversion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public function getMySqlTables()
'm2epro_registry',

'm2epro_lock_item',
'm2epro_lock_transactional',
'm2epro_locked_object',
'm2epro_product_change',
'm2epro_operation_history',
Expand Down
12 changes: 12 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Amazon/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ public function getGrandTotalPrice()
$this->grandTotalPrice = $this->getSubtotalPrice();
$this->grandTotalPrice += $this->getProductPriceTaxAmount();
$this->grandTotalPrice += $this->getShippingPrice();
$this->grandTotalPrice += $this->getShippingPriceTaxAmount();
$this->grandTotalPrice += $this->getGiftPriceTaxAmount();
$this->grandTotalPrice -= $this->getPromotionDiscountAmount();
$this->grandTotalPrice -= $this->getShippingDiscountAmount();
Expand Down Expand Up @@ -753,6 +754,17 @@ public function refund(array $items = array())
if ($this->isShipped() || $this->isPartiallyShipped() || count($items) != $totalItemsCount ||
$this->isLockedObject('update_shipping_status') || $changeCollection->getSize() > 0
) {
if (empty($items)) {
$this->getParentObject()->addErrorLog(
'Amazon Order was not refunded. Reason: %msg%',
array('msg' => 'Refund request was not submitted.
To be processed through Amazon API, the refund must be applied to certain products
in an order. Please indicate the number of each line item, that need to be refunded,
in Credit Memo form.')
);
return false;
}

$action = Ess_M2ePro_Model_Order_Change::ACTION_REFUND;
}

Expand Down
4 changes: 4 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Amazon/Order/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,10 @@ private function createOrUpdateOrder()

$this->order->save();
$this->order->setAccount($this->account);

if ($this->order->getChildObject()->isCanceled() && $this->order->getReserve()->isPlaced()) {
$this->order->getReserve()->cancel();
}
}

//########################################
Expand Down
53 changes: 42 additions & 11 deletions app/code/community/Ess/M2ePro/Model/Amazon/Order/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@

class Ess_M2ePro_Model_Amazon_Order_Proxy extends Ess_M2ePro_Model_Order_Proxy
{
/** @var $order Ess_M2ePro_Model_Amazon_Order */
/** @var Ess_M2ePro_Model_Amazon_Order */
protected $order = NULL;

/** @var Ess_M2ePro_Model_Amazon_Order_Item_Proxy[] */
protected $removedProxyItems = array();

//########################################

/**
Expand All @@ -20,16 +23,20 @@ class Ess_M2ePro_Model_Amazon_Order_Proxy extends Ess_M2ePro_Model_Order_Proxy
*/
protected function mergeItems(array $items)
{
// Magento order can be created even it has zero price. Tested on Magento v. 1.7.0.2 and greater.
// Doest not requires 'Zero Subtotal Checkout enabled'
$minVersion = Mage::helper('M2ePro/Magento')->isCommunityEdition() ? '1.7.0.2' : '1.12';
if (version_compare(Mage::helper('M2ePro/Magento')->getVersion(), $minVersion, '>=')) {
return parent::mergeItems($items);
}

foreach ($items as $key => $item) {
if ($item->getPrice() <= 0) {
$this->removedProxyItems[] = $item;
unset($items[$key]);
}
}

if (count($items) == 0) {
throw new Ess_M2ePro_Model_Exception('Every Item in Order has zero Price.');
}

return parent::mergeItems($items);
}

Expand Down Expand Up @@ -199,12 +206,13 @@ public function getCurrency()
public function getPaymentData()
{
$paymentData = array(
'method' => Mage::getSingleton('M2ePro/Magento_Payment')->getCode(),
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
'payment_method' => '',
'channel_order_id' => $this->order->getAmazonOrderId(),
'channel_final_fee' => 0,
'transactions' => array()
'method' => Mage::getSingleton('M2ePro/Magento_Payment')->getCode(),
'component_mode' => Ess_M2ePro_Helper_Component_Amazon::NICK,
'payment_method' => '',
'channel_order_id' => $this->order->getAmazonOrderId(),
'channel_final_fee' => 0,
'cash_on_delivery_cost' => 0,
'transactions' => array()
);

return $paymentData;
Expand Down Expand Up @@ -338,6 +346,29 @@ public function getChannelComments()
}
// ---------------------------------------

// Removed Order Items
// ---------------------------------------
if (!empty($this->removedProxyItems)) {

$comment = '<u>'.
Mage::helper('M2ePro')->__(
'The following SKUs have zero price and can not be included in Magento order line items'
).
':</u><br/>';

$zeroItems = array();
foreach ($this->removedProxyItems as $item) {

$productSku = $item->getMagentoProduct()->getSku();
$qtyPurchased = $item->getQty();

$zeroItems[] = "<b>{$productSku}</b>: {$qtyPurchased} QTY";
}

$comments[] = $comment . implode('<br/>,', $zeroItems);
}
// ---------------------------------------

return $comments;
}

Expand Down
13 changes: 7 additions & 6 deletions app/code/community/Ess/M2ePro/Model/Buy/Order/Proxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,13 @@ public function getCurrency()
public function getPaymentData()
{
$paymentData = array(
'method' => Mage::getSingleton('M2ePro/Magento_Payment')->getCode(),
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
'payment_method' => '',
'channel_order_id' => $this->order->getBuyOrderId(),
'channel_final_fee' => 0,
'transactions' => array()
'method' => Mage::getSingleton('M2ePro/Magento_Payment')->getCode(),
'component_mode' => Ess_M2ePro_Helper_Component_Buy::NICK,
'payment_method' => '',
'channel_order_id' => $this->order->getBuyOrderId(),
'channel_final_fee' => 0,
'cash_on_delivery_cost' => 0,
'transactions' => array()
);

return $paymentData;
Expand Down
11 changes: 11 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Cron/Runner/Abstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,28 @@ abstract protected function getInitiator();

public function process()
{
/** @var Ess_M2ePro_Model_Lock_Transactional_Manager $transactionalManager */
$transactionalManager = Mage::getModel('M2ePro/Lock_Transactional_Manager', array(
'nick' => 'cron_runner'
));

$transactionalManager->lock();

$this->initialize();
$this->updateLastAccess();

if (!$this->isPossibleToRun()) {
$this->deInitialize();
$transactionalManager->unlock();

return true;
}

$this->updateLastRun();
$this->beforeStart();

$transactionalManager->unlock();

try {

/** @var Ess_M2ePro_Model_Cron_Strategy_Abstract $strategyObject */
Expand Down
2 changes: 0 additions & 2 deletions app/code/community/Ess/M2ePro/Model/Cron/Runner/Magento.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ protected function getStrategyObject()

protected function initialize()
{
usleep(rand(0,2000000));

parent::initialize();

$helper = Mage::helper('M2ePro/Module_Cron');
Expand Down
2 changes: 0 additions & 2 deletions app/code/community/Ess/M2ePro/Model/Cron/Runner/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ public function resetTasksStartFrom()

protected function initialize()
{
usleep(rand(0,2000000));

parent::initialize();

$helper = Mage::helper('M2ePro/Module_Cron');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

abstract class Ess_M2ePro_Model_Cron_Strategy_Abstract
{
const INITIALIZATION_TRANSACTIONAL_LOCK_NICK = 'cron_strategy_initialization';

private $initiator = null;

private $allowedTasks = NULL;
Expand Down
Loading

0 comments on commit 24af9c5

Please sign in to comment.