Skip to content

Commit

Permalink
6.13.1 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
raisaev committed May 27, 2021
1 parent fb6bd54 commit 1462fcf
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 4 deletions.
6 changes: 5 additions & 1 deletion app/code/community/Ess/M2ePro/CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
* 6.13.0 (r16265) (17/05/2021)
* 6.13.1 (r16274) (27/05/2021)

eBay: [Fixed] eBay Store Category IDs are not saved correctly [M1-1242]

* 6.13.0 (r16264) (17/05/2021)

Common: [Fixed] Fatal error 'CategoryTemplate with same data already exists' occurs when moving the Product from the Unmanaged Listing to the M2E Listing [M1-1125]
Common: [Fixed] Products are not displayed on the Search page of the M2E Pro Listing after applying filtering by price [M1-1173]
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Ess/M2ePro/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "m2epro/magento1-extension",
"description": "M2E Pro is a Magento trusted (TM), award-winning extension, which allows merchants of all sizes to fully integrate Magento based system(s) into eBay/Amazon/Walmart platforms.",
"type": "magento-module",
"version": "6.13.0",
"version": "6.13.1",
"license": "proprietary",
"keywords": ["ebay", "amazon", "walmart", "magento"],
"homepage": "https://www.m2epro.com/",
Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Ess/M2ePro/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Ess_M2ePro>
<version>6.13.0</version>
<version>6.13.1</version>
</Ess_M2ePro>
</modules>
<default>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
<?php

// @codingStandardsIgnoreFile

class Ess_M2ePro_Sql_Update_y21_m05_EbayStoreCategoryIDs extends Ess_M2ePro_Model_Upgrade_Feature_AbstractFeature
{
//########################################

public function execute()
{
$ebayTemplateStoreCategoryTable = $this->_installer->getFullTableName('ebay_template_store_category');

$query = $this->_installer->getConnection()
->select()
->from($ebayTemplateStoreCategoryTable)
->where('category_id = ?', 4294967295)
->query();

$accountStoreCategoriesCache = array();

while ($row = $query->fetch()) {
if (empty($accountStoreCategoriesCache[$row['account_id']])) {
$accountStoreCategoriesCache[$row['account_id']] = $this->getEbayStoreCategories($row['account_id']);
}

$category = $this->findCategoryByPath(
$row['category_path'],
$accountStoreCategoriesCache[$row['account_id']]
);

if ($category !== null) {
$this->_installer->getConnection()->update(
$ebayTemplateStoreCategoryTable,
array('category_id' => $category['category_id']),
array('id = ?' => $row['id'])
);
}
}

$listingTable = $this->_installer->getFullTableName('listing');
$listingProductTable = $this->_installer->getFullTableName('listing_product');
$ebayListingProductTable = $this->_installer->getFullTableName('ebay_listing_product');

$listingProductsQuery = $this->_installer->getConnection()->query(
<<<SQL
SELECT `ml`.account_id,
`ml`.marketplace_id ,
`mlp`.listing_id,
`mlp`.product_id,
`melp`.listing_product_id,
`ml`.title as listing_title,
`melp`.online_title as product_title
FROM `{$listingProductTable}` as `mlp`
JOIN `{$ebayListingProductTable}` as melp on `mlp`.id = melp.listing_product_id
JOIN `{$listingTable}` as `ml` on `mlp`.listing_id = `ml`.id
WHERE `melp`.`template_store_category_id` IN (
SELECT * FROM ( SELECT id FROM `{$ebayTemplateStoreCategoryTable}` WHERE `category_id` = 4294967295 ) AS subquery
)
SQL
);

$listingLogTable = $this->_installer->getFullTableName('listing_log');
$catalogProductEntityVarcharTable = Mage::getSingleton('core/resource')
->getTableName('catalog_product_entity_varchar');
$eavAttributeTable = Mage::getSingleton('core/resource')->getTableName('eav_attribute');

$logActionId = $this->getNextLogActionId();
$nowDate = new DateTime();
$nowDate = $nowDate->format('Y-m-d H:i:s');

while ($row = $listingProductsQuery->fetch()) {
$productTitle = $this->_installer->getConnection()->query(
<<<SQL
SELECT `value`
FROM `{$catalogProductEntityVarcharTable}` as `cpev`
LEFT JOIN `{$eavAttributeTable}` as `ea` ON `ea`.attribute_id = cpev.attribute_id
WHERE `ea`.attribute_code = 'name' AND `cpev`.entity_id = {$row['product_id']}
SQL
)->fetch();

$productTitle = $productTitle['value'];

$this->_installer->getConnection()->insert(
$listingLogTable,
array(
'account_id' => $row['account_id'],
'marketplace_id' => $row['marketplace_id'],
'listing_id' => $row['listing_id'],
'product_id' => $row['product_id'],
'listing_product_id' => $row['listing_product_id'],
'listing_title' => $row['listing_title'],
'product_title' => empty($productTitle) ?
empty($row['product_title']) ? '[Product Title]' : $row['product_title'] :
$productTitle,
'initiator' => 2, // INITIATOR_EXTENSION
'action_id' => $logActionId,
'action' => 1, // ACTION_UNKNOWN
'type' => 3, // TYPE_WARNING
'description' => <<<TEXT
The specified eBay Store category ID is invalid. Please select the correct eBay Store category ID for this Product.
TEXT
,
'component_mode' => 'ebay',
'additional_data' => json_encode(array()),
'create_date' => $nowDate
)
);
}
}

private function getEbayStoreCategories($accountId)
{
$query = $this->_installer->getConnection()
->select()
->from($this->_installer->getFullTableName('ebay_account_store_category'))
->where('`account_id` = ?', (int)$accountId)
->order(array('sorder ASC'));

return $this->_installer->getConnection()->fetchAll($query);
}

private function findCategoryByPath($categoryPath, $categories)
{
$path = array_map('trim', array_reverse(explode('>', $categoryPath)));

$lastParentId = 0;
$lastCategory = null;
$resultCategory = null;

foreach ($path as $pathPart) {
foreach ($categories as $category) {
if ($category['parent_id'] == $lastParentId && $category['title'] == $pathPart) {
$lastParentId = $category['category_id'];
$lastCategory = $category;
break;
}
}

if ($lastCategory['title'] == $pathPart) {
$resultCategory = $lastCategory;
} else {
$resultCategory = null;
}
}

return $resultCategory;
}

private function getNextLogActionId()
{
$config = $this->_installer->getMainConfigModifier()->getEntity(
'/logs/listings/',
'last_action_id'
);

$value = $config->getValue() + 1;
$config->updateValue($value);

return $value;
}

//########################################
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

/*
* @author M2E Pro Developers Team
* @copyright M2E LTD
* @license Commercial use is forbidden
*/

class Ess_M2ePro_Sql_Upgrade_v6_13_0__v6_13_1_Config extends Ess_M2ePro_Model_Upgrade_Feature_AbstractConfig
{
//########################################

public function getFeaturesList()
{
return array(
'@y21_m05/EbayStoreCategoryIDs'
);
}

//########################################
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "m2epro/magento1-extension",
"description": "M2E Pro is a Magento trusted (TM), award-winning extension, which allows merchants of all sizes to fully integrate Magento based system(s) into eBay/Amazon/Walmart platforms.",
"type": "magento-module",
"version": "6.13.0",
"version": "6.13.1",
"license": "proprietary",
"keywords": ["ebay", "amazon", "walmart", "magento"],
"homepage": "https://www.m2epro.com/",
Expand Down

0 comments on commit 1462fcf

Please sign in to comment.