Skip to content

Commit

Permalink
6.4.9 RELEASE FINAL
Browse files Browse the repository at this point in the history
  • Loading branch information
d-belousov committed May 10, 2017
1 parent 89a90ad commit f0596dd
Show file tree
Hide file tree
Showing 30 changed files with 394 additions and 3,604 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class Ess_M2ePro_Block_Adminhtml_Renderer_Description_Gallery
extends Ess_M2ePro_Block_Adminhtml_Renderer_Description_Abstract
{
private $galleryId;

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

public function __construct()
Expand All @@ -24,4 +26,40 @@ public function __construct()
}

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

public function getGalleryId()
{
if (is_null($this->galleryId)) {
$this->galleryId = substr(sha1(
'gallery-' . $this->getData('index_number') . json_encode($this->getGalleryImages())
), 20);
}
return $this->galleryId;
}

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

public function isModeGallery()
{
return $this->getData('linked_mode') == Ess_M2ePro_Helper_Module_Renderer_Description::IMAGES_MODE_GALLERY;
}

public function isLinkMode()
{
return $this->getData('linked_mode') == Ess_M2ePro_Helper_Module_Renderer_Description::IMAGES_MODE_NEW_WINDOW;
}

public function isLayoutColumnMode()
{
return $this->getData('layout') == Ess_M2ePro_Helper_Module_Renderer_Description::LAYOUT_MODE_COLUMN;
}

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

public function getGalleryImages()
{
return $this->getData('images') ? $this->getData('images') : array();
}

//########################################
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
class Ess_M2ePro_Block_Adminhtml_Renderer_Description_Image
extends Ess_M2ePro_Block_Adminhtml_Renderer_Description_Abstract
{
private $imageId;

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

public function __construct()
Expand All @@ -24,4 +26,23 @@ public function __construct()
}

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

public function getImageId()
{
if (is_null($this->imageId)) {
$this->imageId = substr(sha1(
'image-' . $this->getData('index_number') . json_encode($this->getData('src'))
), 20);
}
return $this->imageId;
}

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

public function isLinkMode()
{
return $this->getData('linked_mode') == Ess_M2ePro_Helper_Module_Renderer_Description::IMAGES_MODE_NEW_WINDOW;
}

//########################################
}
15 changes: 15 additions & 0 deletions app/code/community/Ess/M2ePro/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
* 6.4.9 (r11403) (09/05/2017)

* Added: [eBay] Ability to use Parts Compatibility Feature for Spain (kTypes)
* Improvement: Some sort of new protection to prevent Magento Orders to be duplicated
* Improvement: Ignore Channel Orders that were created earlier than M2E Pro Account was created
* Improvement: [eBay] M2E Pro Images Gallery uses CSS instead of JS (eBay active content deprecation announcement)
* Fix: A simple with Custom Options product is considered to be a Variational by mistake (in some cases)
* Fix: Undefined constant TYPE_DB_UPGRADE during an upgrade process (only if Magento versions less than 1.5.x)
* Fix: Magento Order for Configurable Products was not created (the limited set of cases)
* Fix: [eBay] Order Variation Options were not mapped automatically for Grouped Products in some cases
* Fix: [eBay] Incorrect Status of Listing Product displayed in Listing Grid, if Out Of Stock Control enabled (Sold instead of Stopped) in some cases
* Fix: [eBay] Not paid Orders could be automatically canceled earlier than allowed period was ended
* Fix: [Amazon] Error when new Variational Product was added to the Listing because it was not considered as Parent-Child Amazon Product
* Fix: [Amazon] Some QTY amount was not returned back for AFN Orders if Magento Product QTY was lower or equal to zero

* 6.4.8 (r11156) (06/02/2017)

* Added: [eBay] Ability to use Parts Compatibility Feature for France Marketplace (kTypes)
Expand Down
10 changes: 10 additions & 0 deletions app/code/community/Ess/M2ePro/Helper/Component/Ebay.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Ess_M2ePro_Helper_Component_Ebay extends Mage_Core_Helper_Abstract
const MARKETPLACE_FR = 7;
const MARKETPLACE_DE = 8;
const MARKETPLACE_IT = 10;
const MARKETPLACE_ES = 13;

const LISTING_DURATION_GTC = 100;
const MAX_LENGTH_FOR_OPTION_VALUE = 50;
Expand Down Expand Up @@ -258,6 +259,15 @@ public function reduceOptionsForVariations(array $options)
public function reduceOptionsForOrders(array $options)
{
foreach ($options as &$singleOption) {
if ($singleOption instanceof Mage_Catalog_Model_Product) {
$reducedName = Mage::helper('M2ePro')->reduceWordsInString(
$singleOption->getName(), self::MAX_LENGTH_FOR_OPTION_VALUE
);
$singleOption->setData('name', $reducedName);

continue;
}

foreach ($singleOption['values'] as &$singleOptionValue) {
foreach ($singleOptionValue['labels'] as &$singleOptionLabel) {
$singleOptionLabel = Mage::helper('M2ePro')->reduceWordsInString(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function getKtypeSupportedMarketplaces()
Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_DE,
Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_IT,
Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_FR,
Ess_M2ePro_Helper_Component_Ebay::MARKETPLACE_ES,
);
}

Expand Down
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 = '11156';
$revision = '11403';

if ($revision == str_replace('|','#','|REVISION|')) {
$revision = (int)exec('svnversion');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,9 @@ private function insertImages($text, Ess_M2ePro_Model_Magento_Product $magentoPr

$imageLink = $magentoProduct->getImageLink('image');

$blockObj = Mage::getSingleton('core/layout')->createBlock(
'M2ePro/adminhtml_renderer_description_image'
);

$search = array();
$replace = array();

foreach ($matches[0] as $key => $match) {

$tempImageAttributes = explode(',', $matches[1][$key]);
Expand All @@ -120,13 +117,18 @@ private function insertImages($text, Ess_M2ePro_Model_Magento_Product $magentoPr
? $imageLink
: $magentoProduct->getGalleryImageLink($realImageAttributes[5]);

$blockObj = Mage::getSingleton('core/layout')->createBlock(
'M2ePro/adminhtml_renderer_description_image'
);

$data = array(
'width' => $realImageAttributes[0],
'height' => $realImageAttributes[1],
'margin' => $realImageAttributes[2],
'linked_mode' => $realImageAttributes[3],
'watermark' => $realImageAttributes[4],
'src' => $tempImageLink
'width' => $realImageAttributes[0],
'height' => $realImageAttributes[1],
'margin' => $realImageAttributes[2],
'linked_mode' => $realImageAttributes[3],
'watermark' => $realImageAttributes[4],
'src' => $tempImageLink,
'index_number' => $key
);
$search[] = $match;
$replace[] = ($tempImageLink == '')
Expand All @@ -147,13 +149,9 @@ private function insertMediaGalleries($text, Ess_M2ePro_Model_Magento_Product $m
return $text;
}

$blockObj = Mage::getSingleton('core/layout')->createBlock(
'M2ePro/adminhtml_renderer_description_gallery'
);

$search = array();
$replace = array();
$attributeCounter = 0;

foreach ($matches[0] as $key => $match) {
$tempMediaGalleryAttributes = explode(',', $matches[1][$key]);
$realMediaGalleryAttributes = array();
Expand Down Expand Up @@ -188,20 +186,16 @@ private function insertMediaGalleries($text, Ess_M2ePro_Model_Magento_Product $m
'linked_mode' => (int)$realMediaGalleryAttributes[3],
'layout' => $realMediaGalleryAttributes[4],
'gallery_hint' => trim($realMediaGalleryAttributes[6], '"'),
'watermark' => (int)$realMediaGalleryAttributes[7],
'images_count' => count($galleryImagesLinks),
'image_counter' => 0
'watermark' => (int)$realMediaGalleryAttributes[7],
'images' => $galleryImagesLinks,
'index_number' => $key
);

$tempHtml = '';
$attributeCounter++;
$blockObj = Mage::getSingleton('core/layout')->createBlock(
'M2ePro/adminhtml_renderer_description_gallery'
);
$tempHtml = $blockObj->setData($data)->toHtml();

foreach ($galleryImagesLinks as $imageLink) {
$data['image_counter']++;
$data['attribute_counter'] = $attributeCounter;
$data['src'] = $imageLink;
$tempHtml .= $blockObj->addData($data)->toHtml();
}
$search[] = $match;
$replace[] = preg_replace('/\s{2,}/', '', $tempHtml);
}
Expand Down
17 changes: 17 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Amazon/Listing/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,23 @@ public function deleteInstance()

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

public function afterSaveNewEntity()
{
/** @var Ess_M2ePro_Model_Amazon_Listing_Product_Variation_Manager $variationManager */
$variationManager = $this->getVariationManager();
$magentoProduct = $this->getMagentoProduct();

if ($magentoProduct->isProductWithVariations() && !$variationManager->isVariationProduct()) {

$this->getParentObject()->setData('is_variation_product', 1);
$variationManager->setRelationParentType();
$variationManager->getTypeModel()->resetProductAttributes(false);
$variationManager->getTypeModel()->getProcessor()->process();
}
}

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

/**
* @return Ess_M2ePro_Model_Account
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,17 @@ protected function processResponseData($response)

private function processAmazonOrders($response, Ess_M2ePro_Model_Account $account)
{
$accountCreateDate = new DateTime($account->getData('create_date'), new DateTimeZone('UTC'));

$orders = array();

foreach ($response as $orderData) {

$orderCreateDate = new DateTime($orderData['purchase_create_date'], new DateTimeZone('UTC'));
if ($orderCreateDate < $accountCreateDate) {
continue;
}

/** @var $orderBuilder Ess_M2ePro_Model_Amazon_Order_Builder */
$orderBuilder = Mage::getModel('M2ePro/Amazon_Order_Builder');
$orderBuilder->initialize($account, $orderData);
Expand All @@ -140,6 +147,11 @@ private function createMagentoOrders($amazonOrders)
{
foreach ($amazonOrders as $order) {
/** @var $order Ess_M2ePro_Model_Order */

if ($this->isOrderChangedInParallelProcess($order)) {
continue;
}

$order->getLog()->setInitiator(Ess_M2ePro_Helper_Data::INITIATOR_EXTENSION);

if ($order->canCreateMagentoOrder()) {
Expand All @@ -166,6 +178,24 @@ private function createMagentoOrders($amazonOrders)
}
}

/**
* This is going to protect from Magento Orders duplicates.
* (Is assuming that there may be a parallel process that has already created Magento Order)
*
* But this protection is not covering a cases when two parallel cron processes are isolated by mysql transactions
*/
private function isOrderChangedInParallelProcess(Ess_M2ePro_Model_Order $order)
{
/** @var Ess_M2ePro_Model_Order $dbOrder */
$dbOrder = Mage::getModel('M2ePro/Order')->load($order->getId());

if ($dbOrder->getMagentoOrderId() != $order->getMagentoOrderId()) {
return true;
}

return false;
}

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

private function getSynchronizationLog()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ private function createMagentoOrders($buyOrders)
{
foreach ($buyOrders as $order) {
/** @var $order Ess_M2ePro_Model_Order */

if ($this->isOrderChangedInParallelProcess($order)) {
continue;
}

if ($order->canCreateMagentoOrder()) {
try {
$order->createMagentoOrder();
Expand All @@ -149,6 +154,24 @@ private function createMagentoOrders($buyOrders)
}
}

/**
* This is going to protect from Magento Orders duplicates.
* (Is assuming that there may be a parallel process that has already created Magento Order)
*
* But this protection is not covering a cases when two parallel cron processes are isolated by mysql transactions
*/
private function isOrderChangedInParallelProcess(Ess_M2ePro_Model_Order $order)
{
/** @var Ess_M2ePro_Model_Order $dbOrder */
$dbOrder = Mage::getModel('M2ePro/Order')->load($order->getId());

if ($dbOrder->getMagentoOrderId() != $order->getMagentoOrderId()) {
return true;
}

return false;
}

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

/**
Expand Down
4 changes: 4 additions & 0 deletions app/code/community/Ess/M2ePro/Model/Ebay/Listing/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ public function deleteInstance()

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

public function afterSaveNewEntity() {}

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

/**
* @return Ess_M2ePro_Model_Ebay_Item
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,6 +381,7 @@ private function getProductStatusChanges(Ess_M2ePro_Model_Listing_Product $listi

if (($change['listingStatus'] == self::EBAY_STATUS_COMPLETED ||
$change['listingStatus'] == self::EBAY_STATUS_ENDED) &&
$listingProduct->getStatus() != Ess_M2ePro_Model_Listing_Product::STATUS_HIDDEN &&
$qty == $qtySold) {

$data['status'] = Ess_M2ePro_Model_Listing_Product::STATUS_SOLD;
Expand Down
Loading

0 comments on commit f0596dd

Please sign in to comment.