Skip to content

Commit

Permalink
6.31.0 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Oct 19, 2022
1 parent 64361a9 commit ccee5ee
Show file tree
Hide file tree
Showing 34 changed files with 629 additions and 225 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@
* @method bool getEnabledKtype()
* @method Ess_M2ePro_Model_Marketplace getUkMarketplace()
* @method Ess_M2ePro_Model_Marketplace getDeMarketplace()
* @method Ess_M2ePro_Model_Marketplace getAuMarketplace()
* @method Ess_M2ePro_Model_Marketplace getMotorsMarketplace()
* @method Ess_M2ePro_Model_Marketplace getItMarketplace()
* @method array getAvailabilityAttributes()
* @method int getUkEpidCount()
* @method int getUkEpidCustomCount()
* @method int getDeEpidCount()
* @method int getDeEpidCustomCount()
* @method int getAuEpidCount()
* @method int getAuEpidCustomCount()
* @method int getItEpidCount()
* @method int getItEpidCustomCount()
* @method int getMotorsEpidCount()
* @method int getMotorsEpidCustomCount()
* @method int getKtypeCount()
Expand Down Expand Up @@ -90,6 +90,10 @@ protected function _beforeToHtml()
'au_marketplace',
$eBayHelper->getCachedObject('Marketplace', Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_AU)
);
$this->setData(
'it_marketplace',
$eBayHelper->getCachedObject('Marketplace', Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_IT)
);
$this->setData(
'motors_marketplace',
$eBayHelper->getCachedObject('Marketplace', Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_MOTORS)
Expand All @@ -114,10 +118,10 @@ protected function _beforeToHtml()
$this->setData('de_epid_count', $count);

list($count, $customCount) = $eBayMotorsHelper->getDictionaryRecordCount(
Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_EPID_AU
Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_EPID_IT
);
$this->setData('au_epid_custom_count', $customCount);
$this->setData('au_epid_count', $count);
$this->setData('it_epid_custom_count', $customCount);
$this->setData('it_epid_count', $count);

list($count, $customCount) = $eBayMotorsHelper->getDictionaryRecordCount(
Ess_M2ePro_Helper_Component_Ebay_Motors::TYPE_EPID_MOTOR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ public function getDeEpidsAttribute()
);
}

public function getAuEpidsAttribute()
public function getItEpidsAttribute()
{
return Mage::helper('M2ePro/Module')->getConfig()->getGroupValue(
self::CONFIG_GROUP, 'au_epids_attribute'
self::CONFIG_GROUP, 'it_epids_attribute'
);
}

Expand Down Expand Up @@ -185,8 +185,8 @@ public function setConfigValues(array $values)
$motorsAttributes[] = $values['de_epids_attribute'];
}

if (isset($values['au_epids_attribute'])) {
$motorsAttributes[] = $values['au_epids_attribute'];
if (isset($values['it_epids_attribute'])) {
$motorsAttributes[] = $values['it_epids_attribute'];
}

if (isset($values['motors_epids_attribute'])) {
Expand All @@ -213,9 +213,9 @@ public function setConfigValues(array $values)
);
}

if (isset($values['au_epids_attribute'])) {
if (isset($values['it_epids_attribute'])) {
Mage::helper('M2ePro/Module')->getConfig()->setGroupValue(
self::CONFIG_GROUP, 'au_epids_attribute', $values['au_epids_attribute']
self::CONFIG_GROUP, 'it_epids_attribute', $values['it_epids_attribute']
);
}

Expand Down
30 changes: 17 additions & 13 deletions app/code/community/Ess/M2ePro/Helper/Component/Ebay/Motors.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ class Ess_M2ePro_Helper_Component_Ebay_Motors extends Mage_Core_Helper_Abstract
const TYPE_KTYPE = 2;
const TYPE_EPID_UK = 3;
const TYPE_EPID_DE = 4;
const TYPE_EPID_AU = 5;
const TYPE_EPID_IT = 6;

const EPID_SCOPE_MOTORS = 1;
const EPID_SCOPE_UK = 2;
const EPID_SCOPE_DE = 3;
const EPID_SCOPE_AU = 4;
const EPID_SCOPE_IT = 5;

const PRODUCT_TYPE_VEHICLE = 0;
const PRODUCT_TYPE_MOTORCYCLE = 1;
Expand All @@ -42,8 +42,8 @@ public function getAttribute($type)
case self::TYPE_EPID_DE:
return Mage::helper('M2ePro/Component_Ebay_Configuration')->getDeEpidsAttribute();

case self::TYPE_EPID_AU:
return Mage::helper('M2ePro/Component_Ebay_Configuration')->getAuEpidsAttribute();
case self::TYPE_EPID_IT:
return Mage::helper('M2ePro/Component_Ebay_Configuration')->getItEpidsAttribute();
}

return '';
Expand Down Expand Up @@ -203,11 +203,15 @@ public function buildGroupAttributeValue(array $groups)

public function isTypeBasedOnEpids($type)
{
if (in_array($type, array(self::TYPE_EPID_MOTOR, self::TYPE_EPID_UK, self::TYPE_EPID_DE, self::TYPE_EPID_AU))) {
return true;
}

return false;
return in_array(
$type,
array(
self::TYPE_EPID_MOTOR,
self::TYPE_EPID_UK,
self::TYPE_EPID_DE,
self::TYPE_EPID_IT
)
);
}

public function isTypeBasedOnKtypes($type)
Expand Down Expand Up @@ -261,8 +265,8 @@ public function getEpidsScopeByType($type)
case self::TYPE_EPID_DE:
return self::EPID_SCOPE_DE;

case self::TYPE_EPID_AU:
return self::EPID_SCOPE_AU;
case self::TYPE_EPID_IT:
return self::EPID_SCOPE_IT;

default:
return null;
Expand All @@ -281,8 +285,8 @@ public function getEpidsTypeByMarketplace($marketplaceId)
case Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_DE:
return self::TYPE_EPID_DE;

case Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_AU:
return self::TYPE_EPID_AU;
case Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_IT:
return self::TYPE_EPID_IT;

default:
return null;
Expand Down
12 changes: 12 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Amazon/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ public function isImportShipByDateToMagentoOrder()
);
}

/**
* @return bool
*/
public function isUpdateWithoutTrackToMagentoOrder()
{
return (bool)$this->getSetting(
'magento_orders_settings',
array('shipping_information', 'update_without_track'),
true
);
}

// ---------------------------------------

/**
Expand Down
22 changes: 17 additions & 5 deletions app/code/community/Ess/M2ePro/Model/Amazon/Account/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,10 +321,21 @@ protected function prepareData()
}
}

$data['magento_orders_settings']['shipping_information']['ship_by_date']
= isset($this->_rawData['magento_orders_settings']['shipping_information']['ship_by_date'])
? (int)$this->_rawData['magento_orders_settings']['shipping_information']['ship_by_date']
: 1;
// shipping information
// ---------------------------------------
$tempKey = 'shipping_information';
$tempSettings = !empty($this->_rawData['magento_orders_settings'][$tempKey])
? $this->_rawData['magento_orders_settings'][$tempKey] : array();

$keys = array(
'ship_by_date',
'update_without_track',
);
foreach ($keys as $key) {
if (isset($tempSettings[$key])) {
$data['magento_orders_settings'][$tempKey][$key] = $tempSettings[$key];
}
}

$data['magento_orders_settings'] = Mage::helper('M2ePro')
->jsonEncode($data['magento_orders_settings']);
Expand Down Expand Up @@ -427,7 +438,8 @@ public function getDefaultData()
'stock_mode' => 0
),
'shipping_information' => array(
'ship_by_date' => 1,
'ship_by_date' => 1,
'update_without_track' => 1,
),
),

Expand Down
6 changes: 6 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Amazon/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,13 +710,19 @@ public function canUpdateShippingStatus(array $trackingDetails = array())
* @param array $trackingDetails
* @param array $items
* @return bool
* @throws Ess_M2ePro_Model_Exception_Logic
*/
public function updateShippingStatus(array $trackingDetails = array(), array $items = array())
{
if (!$this->canUpdateShippingStatus($trackingDetails)) {
return false;
}

if (empty($trackingDetails['carrier_code'])
&& !$this->getAmazonAccount()->isUpdateWithoutTrackToMagentoOrder()) {
return false;
}

if (!isset($trackingDetails['fulfillment_date'])) {
$trackingDetails['fulfillment_date'] = Mage::helper('M2ePro')->getCurrentGmtDate();
}
Expand Down
27 changes: 24 additions & 3 deletions app/code/community/Ess/M2ePro/Model/Amazon/Order/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,18 @@ protected function createOrUpdateItems()

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

/**
* @param ?Mage_Sales_Model_Order $magentoOrder
*
* @return bool
*/
protected function isMagentoOrderUpdatable($magentoOrder)
{
return $magentoOrder !== null
&& $magentoOrder->getState() !== Mage_Sales_Model_Order::STATE_CLOSED
&& $magentoOrder->getState() !== Mage_Sales_Model_Order::STATE_CANCELED;
}

/**
* @return bool
*/
Expand Down Expand Up @@ -472,7 +484,11 @@ protected function hasUpdate($update)

protected function processMagentoOrderUpdates()
{
if (!$this->hasUpdates() || $this->_order->getMagentoOrder() === null) {
$magentoOrder = $this->_order->getMagentoOrder();
if (!$this->hasUpdates()
|| $magentoOrder === null
|| !$this->isMagentoOrderUpdatable($magentoOrder)
) {
return;
}

Expand All @@ -484,7 +500,7 @@ protected function processMagentoOrderUpdates()

/** @var $magentoOrderUpdater Ess_M2ePro_Model_Magento_Order_Updater */
$magentoOrderUpdater = Mage::getModel('M2ePro/Magento_Order_Updater');
$magentoOrderUpdater->setMagentoOrder($this->_order->getMagentoOrder());
$magentoOrderUpdater->setMagentoOrder($magentoOrder);

if ($this->hasUpdate(self::UPDATE_STATUS)) {
$this->_order->setStatusUpdateRequired(true);
Expand Down Expand Up @@ -529,9 +545,14 @@ protected function cancelMagentoOrder()

private function addCommentsToMagentoOrder(Ess_M2ePro_Model_Order $order, $comments)
{
$magentoOrder = $order->getMagentoOrder();
if (!$this->isMagentoOrderUpdatable($magentoOrder)) {
return;
}

/** @var $magentoOrderUpdater Ess_M2ePro_Model_Magento_Order_Updater */
$magentoOrderUpdater = Mage::getModel('M2ePro/Magento_Order_Updater');
$magentoOrderUpdater->setMagentoOrder($order->getMagentoOrder());
$magentoOrderUpdater->setMagentoOrder($magentoOrder);
$magentoOrderUpdater->updateComments($comments);
$magentoOrderUpdater->finishUpdate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public function process(array $listingsProductsRepricing)
}
}

if (!$this->sendData($changesData)) {
if (empty($changeData) || !$this->sendData($changesData)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,16 @@ public function createMagentoOrder(Ess_M2ePro_Model_Order $order)
}
}

$magentoOrder = $order->getMagentoOrder();
if ($magentoOrder !== null
&& (
$magentoOrder->getState() === Mage_Sales_Model_Order::STATE_CLOSED
|| $magentoOrder->getState() === Mage_Sales_Model_Order::STATE_CANCELED
)
) {
return;
}

if ($order->getReserve()->isNotProcessed() && $order->isReservable()) {
$order->getReserve()->place();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ protected function getChangesByAccount(Ess_M2ePro_Model_Account $account)
return (array)$response;
}

if ($this->_isErrorMessageReceived) {
if ($this->_isErrorMessageReceived && !$this->_isResultSetTooLarge) {
return array();
}

Expand All @@ -211,7 +211,7 @@ protected function getChangesByAccount(Ess_M2ePro_Model_Account $account)
return (array)$response;
}

if ($this->_isErrorMessageReceived) {
if ($this->_isErrorMessageReceived && !$this->_isResultSetTooLarge) {
return array();
}
}
Expand Down
Loading

0 comments on commit ccee5ee

Please sign in to comment.