Skip to content

Commit

Permalink
1.63.0 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Jul 1, 2024
1 parent 4a0659f commit 06c9df1
Show file tree
Hide file tree
Showing 19 changed files with 239 additions and 47 deletions.
18 changes: 16 additions & 2 deletions Block/Adminhtml/Magento/Product/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,22 @@ public function getMassactionBlockHtml()
$advancedFilterBlock = $this->getLayout()->createBlock(\Ess\M2ePro\Block\Adminhtml\Listing\Product\Rule::class);
$advancedFilterBlock->setShowHideProductsOption($this->showAdvancedFilterProductsOption);
$advancedFilterBlock->setGridJsObjectName($this->getJsObjectName());
$advancedFilterBlock->setSearchBtnHtml($this->getSearchButtonHtml());
$advancedFilterBlock->setResetBtnHtml($this->getResetFilterButtonHtml());

$searchFilterBtn = $this->getLayout()->createBlock(\Ess\M2ePro\Block\Adminhtml\Magento\Button::class);
$searchFilterBtn->setData([
'label' => __('Search'),
'class' => 'action-default scalable action-secondary',
'onclick' => $this->getJsObjectName() . '.doFilter()',
]);
$advancedFilterBlock->setSearchBtnHtml($searchFilterBtn->toHtml());

$resetFilterBtn = $this->getLayout()->createBlock(\Ess\M2ePro\Block\Adminhtml\Magento\Button::class);
$resetFilterBtn->setData([
'label' => __('Reset Filter'),
'class' => 'action-default scalable action-reset action-tertiary',
'onclick' => $this->getJsObjectName() . '.resetFilter()',
]);
$advancedFilterBlock->setResetBtnHtml($resetFilterBtn->toHtml());

return $advancedFilterBlock->toHtml() . (($this->hideMassactionColumn)
? '' : parent::getMassactionBlockHtml());
Expand Down
21 changes: 16 additions & 5 deletions Controller/Adminhtml/Ebay/Listing/Edit/SaveCategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,35 @@

class SaveCategory extends \Ess\M2ePro\Controller\Adminhtml\Ebay\Listing\Edit
{
/** @var \Ess\M2ePro\Helper\Data\Cache\Permanent */
private $cachePermanent;
/** @var \Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory */
protected $ebayFactory;
/**@var \Ess\M2ePro\Model\Ebay\ListingFactory */
protected $ebayListingFactory;
/** @var \Ess\M2ePro\Model\ResourceModel\Ebay\Listing */
protected $ebayListingResource;

/** @var \Ess\M2ePro\Model\ListingFactory */
protected $listingFactory;
/** @var \Ess\M2ePro\Model\ResourceModel\Listing */
protected $listingResource;

public function __construct(
\Ess\M2ePro\Helper\Data\Cache\Permanent $cachePermanent,
\Ess\M2ePro\Model\ActiveRecord\Component\Parent\Ebay\Factory $ebayFactory,
\Ess\M2ePro\Controller\Adminhtml\Context $context,
\Ess\M2ePro\Model\Ebay\ListingFactory $ebayListingFactory,
\Ess\M2ePro\Model\ResourceModel\Ebay\Listing $ebayListingResource,
\Ess\M2ePro\Model\ListingFactory $listingFactory,
\Ess\M2ePro\Model\ResourceModel\Listing $listingResource
) {
parent::__construct($ebayFactory, $context);

$this->cachePermanent = $cachePermanent;
$this->listingResource = $listingResource;
$this->listingFactory = $listingFactory;
$this->ebayListingResource = $ebayListingResource;
$this->ebayListingFactory = $ebayListingFactory;
parent::__construct($ebayFactory, $context);
}

public function execute()
Expand All @@ -47,11 +51,18 @@ public function execute()
}
$ebayListing->setAddProductMode($mode);
$this->ebayListingResource->save($ebayListing);
$this->messageManager->addSuccessMessage(__('Category updated successfully.'));

return $this->_redirect('*/*/categories', ['id' => $listingId, '_current' => true]);
} catch (\Exception $e) {
/**
* @see \Ess\M2ePro\Model\Listing::save()
* @see \Ess\M2ePro\Model\Ebay\Listing::save()
*/
$this->cachePermanent->removeTagValues('listing');

$this->messageManager->addSuccessMessage(__('Category updated successfully.'));
} catch (\Throwable $e) {
$this->messageManager->addErrorMessage(__('An error occurred while saving Category'));
}

return $this->_redirect('*/*/categories', ['id' => $listingId, '_current' => true]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ private function stepOne()
$temp = $this->getSessionValue('mode');
$temp && $mode = $temp;

if ($temp === null) {
if ($mode === null) {
$mode = $ebayListing->getAddProductMode();
}

Expand Down
10 changes: 3 additions & 7 deletions Helper/Component/Amazon.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
<?php

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

namespace Ess\M2ePro\Helper\Component;

use Ess\M2ePro\Model\Listing\Product as ListingProduct;
use Ess\M2ePro\Model\ResourceModel\Amazon\Dictionary\TemplateShipping\CollectionFactory
as TemplateShippingDictionaryCollectionFactory;
use Ess\M2ePro\Model\ResourceModel\Marketplace\CollectionFactory;

class Amazon
{
Expand Down Expand Up @@ -40,6 +33,9 @@ class Amazon
public const MARKETPLACE_AE = 47;
public const MARKETPLACE_BE = 48;
public const MARKETPLACE_ZA = 49;
public const MARKETPLACE_SA = 50;

public const NATIVE_ID_MARKETPLACE_SA = 22;

public const EEA_COUNTRY_CODES = [
'AT', 'BE', 'BG', 'HR', 'CY',
Expand Down
1 change: 1 addition & 0 deletions Helper/Component/Amazon/ProductType.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class ProductType
public const SPECIFIC_KEY_ITEM_PACKAGE_WEIGHT = 'item_package_weight#array/value';
public const SPECIFIC_KEY_MAIN_PRODUCT_IMAGE_LOCATOR = 'main_product_image_locator#array/media_location';
public const SPECIFIC_KEY_MAIN_OFFER_IMAGE_LOCATOR = 'main_offer_image_locator#array/media_location';
public const SPECIFIC_KEY_BULLET_POINT = 'bullet_point#array/value';

/** @var ProductTypeCollectionFactory */
private $productTypeCollectionFactory;
Expand Down
2 changes: 2 additions & 0 deletions Helper/Module/Database/Tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Tables
{
public const PREFIX = 'm2epro_';

public const TABLE_MARKETPLACE = self::PREFIX . 'marketplace';
public const TABLE_LISTING = self::PREFIX . 'listing';

public const TABLE_LISTING_PRODUCT = self::PREFIX . 'listing_product';
Expand All @@ -26,6 +27,7 @@ class Tables

public const TABLE_AMAZON_ACCOUNT = self::PREFIX . 'amazon_account';
public const TABLE_AMAZON_ACCOUNT_MERCHANT_SETTING = self::PREFIX . 'amazon_account_merchant_setting';
public const TABLE_AMAZON_MARKETPLACE = self::PREFIX . 'amazon_marketplace';
public const TABLE_AMAZON_LISTING_PRODUCT = self::PREFIX . 'amazon_listing_product';
public const TABLE_AMAZON_ORDER_ITEM = self::PREFIX . 'amazon_order_item';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ private function buildSpecificsData(array $specifics): array
$specificKeys = [
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_NAME,
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_DESCRIPTION,
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_BULLET_POINT,
];

if (in_array($name, $specificKeys)) {
Expand Down
33 changes: 31 additions & 2 deletions Model/AmazonMcf/Amazon/Provider/Product/Repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,15 @@ public function getItemCollection(string $merchantId)
);

foreach ($items as $item) {
$asin = !empty($item->getDataByKey('asin')) ? $item->getDataByKey('asin') : null;
$itemCollection->add(
new \M2E\AmazonMcf\Model\Provider\Amazon\Product\Item(
$this->createItem(
$merchantId,
$item->getDataByKey('channel_sku'),
(int)$item->getDataByKey('magento_product_entity_id'),
$item->getDataByKey('magento_product_sku'),
(int)$item->getDataByKey('online_afn_qty')
(int)$item->getDataByKey('online_afn_qty'),
$asin
)
);
}
Expand Down Expand Up @@ -111,6 +113,7 @@ private function retrieveItems(string $sourceCode, array $accountsIds): array
[
'channel_sku' => sprintf('alp.%s', AmazonListingProductResource::COLUMN_SKU),
'online_afn_qty' => sprintf('alp.%s', AmazonListingProductResource::COLUMN_ONLINE_AFN_QTY),
'asin' => sprintf('alp.%s', AmazonListingProductResource::COLUMN_GENERAL_ID)
]
);

Expand All @@ -133,4 +136,30 @@ private function retrieveItems(string $sourceCode, array $accountsIds): array

return $collection->getItems();
}

/**
* @return \M2E\AmazonMcf\Model\Provider\Amazon\Product\Item
*/
private function createItem(
string $merchantId,
string $channelSku,
int $magentoProductId,
string $magentoProductSku,
int $qty,
?string $asin
) {
$item = new \M2E\AmazonMcf\Model\Provider\Amazon\Product\Item(
$merchantId,
$channelSku,
$magentoProductId,
$magentoProductSku,
$qty
);

if ($asin !== null && method_exists($item, 'setAsin')) {
$item->setAsin($asin);
}

return $item;
}
}
12 changes: 12 additions & 0 deletions Model/Order/EventDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,21 @@ public function dispatchEventsMagentoOrderCreated(\Ess\M2ePro\Model\Order $order
'is_american_region' => $marketplace->isAmericanRegion(),
'is_european_region' => $marketplace->isEuropeanRegion(),
'is_asian_pacific_region' => $marketplace->isAsianPacificRegion(),
'channel_purchase_date' => $this->findPurchaseDate($order),
]);
}

private function findPurchaseDate(\Ess\M2ePro\Model\Order $order): ?\DateTime
{
if ($order->isComponentModeEbay()) {
return \Ess\M2ePro\Helper\Date::createDateGmt(
$order->getChildObject()->getPurchaseCreateDate()
);
}

return null;
}

public function dispatchEventInvoiceCreated(\Ess\M2ePro\Model\Order $order): void
{
$this->eventManager->dispatch('ess_order_invoice_created', [
Expand Down
1 change: 1 addition & 0 deletions Model/ResourceModel/Amazon/Listing/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Product extends \Ess\M2ePro\Model\ResourceModel\ActiveRecord\Component\Chi
public const COLUMN_SKU = 'sku';
public const COLUMN_IS_AFN_CHANNEL = 'is_afn_channel';
public const COLUMN_ONLINE_AFN_QTY = 'online_afn_qty';
public const COLUMN_GENERAL_ID = 'general_id';

/** @var bool */
protected $_isPkAutoIncrement = false;
Expand Down
23 changes: 12 additions & 11 deletions Model/ResourceModel/Amazon/Marketplace.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<?php

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

namespace Ess\M2ePro\Model\ResourceModel\Amazon;

class Marketplace extends \Ess\M2ePro\Model\ResourceModel\ActiveRecord\Component\Child\AbstractModel
{
public const COLUMN_MARKETPLACE_ID = 'marketplace_id';
public const COLUMN_DEFAULT_CURRENCY = 'default_currency';
public const COLUMN_IS_NEW_ASIN_AVAILABLE = 'is_new_asin_available';
public const COLUMN_IS_MERCHANT_FULFILLMENT_AVAILABLE = 'is_merchant_fulfillment_available';
public const COLUMN_IS_BUSINESS_AVAILABLE = 'is_business_available';
public const COLUMN_IS_VAT_CALCULATION_SERVICE_AVAILABLE = 'is_vat_calculation_service_available';
public const COLUMN_IS_PRODUCT_TAX_CODE_POLICY_AVAILABLE = 'is_product_tax_code_policy_available';

/** @var bool */
protected $_isPkAutoIncrement = false;

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

public function _construct()
{
$this->_init('m2epro_amazon_marketplace', 'marketplace_id');
$this->_init(
\Ess\M2ePro\Helper\Module\Database\Tables::TABLE_AMAZON_MARKETPLACE,
self::COLUMN_MARKETPLACE_ID
);
$this->_isPkAutoIncrement = false;
}

//########################################
}
28 changes: 13 additions & 15 deletions Model/ResourceModel/Marketplace.php
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<?php

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

namespace Ess\M2ePro\Model\ResourceModel;

/**
* Class \Ess\M2ePro\Model\ResourceModel\Marketplace
*/
class Marketplace extends ActiveRecord\Component\Parent\AbstractModel
{
//########################################
public const COLUMN_ID = 'id';
public const COLUMN_NATIVE_ID = 'native_id';
public const COLUMN_TITLE = 'title';
public const COLUMN_CODE = 'code';
public const COLUMN_URL = 'url';
public const COLUMN_STATUS = 'status';
public const COLUMN_SORDER = 'sorder';
public const COLUMN_GROUP_TITLE = 'group_title';
public const COLUMN_COMPONENT_MODE = 'component_mode';

public function _construct()
{
$this->_init('m2epro_marketplace', 'id');
$this->_init(
\Ess\M2ePro\Helper\Module\Database\Tables::TABLE_MARKETPLACE,
self::COLUMN_ID
);
}

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

/**
* @param \Ess\M2ePro\Model\Marketplace $marketplace
*/
Expand Down Expand Up @@ -51,6 +51,4 @@ public function isDictionaryExist($marketplace)

return $connection->fetchOne($select) !== false;
}

//########################################
}
28 changes: 26 additions & 2 deletions Model/Setup/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Magento\Framework\Setup\SetupInterface;
use Ess\M2ePro\Model\ResourceModel\Amazon\Order\Item as AmazonOrderItem;
use Ess\M2ePro\Model\ResourceModel\Ebay\Listing\Product as EbayListingProduct;
use Ess\M2ePro\Model\ResourceModel\Marketplace as MarketplaceResource;
use Ess\M2ePro\Model\ResourceModel\Amazon\Marketplace as AmazonMarketplaceResource;

/**
* Installer M2E extension
Expand Down Expand Up @@ -10899,7 +10901,7 @@ private function installAmazonData()
$moduleConfig->insert('/amazon/configuration/', 'general_id_custom_attribute');

$this->getConnection()->insertMultiple(
$this->getFullTableName('marketplace'),
$this->getFullTableName(\Ess\M2ePro\Helper\Module\Database\Tables::TABLE_MARKETPLACE),
[
[
'id' => 24,
Expand Down Expand Up @@ -11161,11 +11163,24 @@ private function installAmazonData()
'update_date' => '2023-12-14 00:00:00',
'create_date' => '2023-12-14 00:00:00',
],
[
MarketplaceResource::COLUMN_ID => 50,
MarketplaceResource::COLUMN_NATIVE_ID => 22,
MarketplaceResource::COLUMN_TITLE => 'Saudi Arabia',
MarketplaceResource::COLUMN_CODE => 'SA',
MarketplaceResource::COLUMN_URL => 'amazon.sa',
MarketplaceResource::COLUMN_STATUS => 0,
MarketplaceResource::COLUMN_SORDER => 23,
MarketplaceResource::COLUMN_GROUP_TITLE => 'Europe',
MarketplaceResource::COLUMN_COMPONENT_MODE => 'amazon',
'update_date' => '2023-06-25 00:00:00',
'create_date' => '2023-06-25 00:00:00',
],
]
);

$this->getConnection()->insertMultiple(
$this->getFullTableName('amazon_marketplace'),
$this->getFullTableName(\Ess\M2ePro\Helper\Module\Database\Tables::TABLE_AMAZON_MARKETPLACE),
[
[
'marketplace_id' => 24,
Expand Down Expand Up @@ -11347,6 +11362,15 @@ private function installAmazonData()
'is_vat_calculation_service_available' => 1,
'is_product_tax_code_policy_available' => 1,
],
[
AmazonMarketplaceResource::COLUMN_MARKETPLACE_ID => 50,
AmazonMarketplaceResource::COLUMN_DEFAULT_CURRENCY => 'SAR',
AmazonMarketplaceResource::COLUMN_IS_NEW_ASIN_AVAILABLE => 1,
AmazonMarketplaceResource::COLUMN_IS_MERCHANT_FULFILLMENT_AVAILABLE => 1,
AmazonMarketplaceResource::COLUMN_IS_BUSINESS_AVAILABLE => 1,
AmazonMarketplaceResource::COLUMN_IS_VAT_CALCULATION_SERVICE_AVAILABLE => 1,
AmazonMarketplaceResource::COLUMN_IS_PRODUCT_TAX_CODE_POLICY_AVAILABLE => 0,
],
]
);
}
Expand Down
1 change: 1 addition & 0 deletions Model/Setup/Upgrader.php
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ class Upgrader
'1.61.0' => ['1.62.0'],
'1.62.0' => ['1.62.1'],
'1.62.1' => ['1.62.2'],
'1.62.2' => ['1.63.0'],
];

//########################################
Expand Down
Loading

0 comments on commit 06c9df1

Please sign in to comment.