Skip to content

Commit

Permalink
1.51.0 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Nov 22, 2023
1 parent 2124b19 commit 7144027
Show file tree
Hide file tree
Showing 48 changed files with 1,140 additions and 571 deletions.
2 changes: 1 addition & 1 deletion Block/Adminhtml/Amazon/Account/Edit/Tabs/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ protected function _prepareForm()
1 => __('Yes'),
0 => __('No'),
],
'value' => $formData['magento_orders_settings']['shipping_information']['update_without_track'] ?? 1,
'value' => $formData['magento_orders_settings']['shipping_information']['update_without_track'] ?? 0,
]
);

Expand Down
9 changes: 9 additions & 0 deletions Block/Adminhtml/Amazon/Template/ProductType/Edit/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ protected function _prepareForm(): Form
]
);

$form->addField(
'is_new_product_type',
'hidden',
[
'value' => !$productType->getId() ? '1' : '0',
'name' => 'is_new_product_type'
]
);

/** @var \Ess\M2ePro\Block\Adminhtml\Amazon\Template\ProductType\Edit\Data $dataBlock */
$dataBlock = $this->getLayout()
->createBlock(
Expand Down
80 changes: 79 additions & 1 deletion Block/Adminhtml/Walmart/Account/Edit/Tabs/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ protected function _prepareForm()
'magento_block_walmart_accounts_magento_orders_listings_other',
[
'legend' => __('Product Is Listed By Any Other Software'),
'collapsable' => false,
'collapsable' => true,
]
);

Expand Down Expand Up @@ -295,6 +295,84 @@ protected function _prepareForm()
]
);

$fieldset = $form->addFieldset(
'magento_block_walmart_accounts_magento_orders_wfs',
[
'legend' => __('WFS Orders Settings'),
'collapsable' => true,
'tooltip' => __(
'In this Block you can manage Stock Inventory of Products fulfilled by Walmart (WFS Orders).<br/>
<b>Yes</b> - after Magento Order Creation of WFS Order, Quantity of Product reduces in Magento.<br/>
<b>No</b> - Magento Order Creation of WFS Order does not affect Quantity of Magento Product.'
),
]
);

$fieldset->addField(
'magento_orders_wfs_mode',
'select',
[
'name' => 'magento_orders_settings[wfs][mode]',
'label' => __('Create Order in Magento'),
'values' => [
0 => __('No'),
1 => __('Yes'),
],
'value' => $formData['magento_orders_settings']['wfs']['mode'] ?? 0,
'tooltip' => __(
'Whether an Order has to be created in Magento if a sold Product is fulfilled by Walmart.'
),
]
);

$fieldset->addField(
'magento_orders_wfs_store_mode',
'select',
[
'container_id' => 'magento_orders_wfs_store_mode_container',
'name' => 'magento_orders_settings[wfs][store_mode]',
'label' => __('Create in separate Store View'),
'values' => [
0 => __('No'),
1 => __('Yes'),
],
'value' => $formData['magento_orders_settings']['wfs']['store_mode'] ?? 0,
]
);

$fieldset->addField(
'magento_orders_wfs_store_id',
self::STORE_SWITCHER,
[
'container_id' => 'magento_orders_wfs_store_id_container',
'name' => 'magento_orders_settings[wfs][store_id]',
'label' => __('Magento Store View'),
'value' => !empty($formData['magento_orders_settings']['wfs']['store_id'])
? $formData['magento_orders_settings']['wfs']['store_id'] : '',
//'required' => true,
'has_empty_option' => true,
'has_default_option' => false,
]
);

$fieldset->addField(
'magento_orders_wfs_stock_mode',
'select',
[
'container_id' => 'magento_orders_wfs_stock_mode_container',
'name' => 'magento_orders_settings[wfs][stock_mode]',
'label' => __('Manage Stock'),
'values' => [
0 => __('No'),
1 => __('Yes'),
],
'value' => $formData['magento_orders_settings']['wfs']['stock_mode'] ?? 0,
'tooltip' => __(
'If <i>Yes</i>, after Magento Order Creation QTY of Magento Product reduces.'
),
]
);

$shippingInfoFieldset = $form->addFieldset(
'magento_block_walmart_accounts_magento_orders_shipping_information',
[
Expand Down
50 changes: 50 additions & 0 deletions Block/Adminhtml/Walmart/Order/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public function _prepareAdvancedFilters()
$this->addMarketplaceAdvancedFilter();
$this->addAccountAdvancedFilter();
$this->addMagentoOrderCreatedFilter();
$this->addIsWfsFilter();
}
protected function _prepareCollection()
{
Expand Down Expand Up @@ -199,6 +200,23 @@ protected function _prepareColumns()
]
);

$this->addColumn(
'is_wfs',
[
'header' => __('Fulfillment'),
'width' => '120px',
'index' => 'is_wfs',
'filter_index' => 'second_table.is_wfs',
'type' => 'options',
'sortable' => false,
'options' => [
0 => __('Merchant'),
1 => __('WALMART'),
],
'frame_callback' => [$this, 'callbackColumnIsWFS'],
]
);

$this->addColumn(
'paid_amount',
[
Expand Down Expand Up @@ -507,6 +525,17 @@ public function callbackColumnBuyer($value, $row, $column, $isExport)
return $this->dataHelper->escapeHtml($row->getChildObject()->getData('buyer_name'));
}

public function callbackColumnIsWFS($value, $row, $column, $isExport)
{
if (
(int)$row->getChildObject()->getData('is_wfs') === 1
) {
return '<span style="font-weight: bold;">' . __('Walmart') . '</span>';
}

return __('Merchant');
}

public function callbackColumnTotal($value, $row, $column, $isExport)
{
$currency = $row->getChildObject()->getData('currency');
Expand Down Expand Up @@ -738,4 +767,25 @@ private function addMagentoOrderCreatedFilter(): void

$this->addAdvancedFilter($filter);
}

private function addIsWfsFilter(): void
{
$options = $this->advancedFilterAllOrdersOptions->getYesNoOptions();

$filterCallback = function (
\Ess\M2ePro\Model\ResourceModel\Order\Collection $orders,
string $filterValue
): void {
$orders->addFieldToFilter('is_wfs', ['eq' => $filterValue]);
};

$filter = $this->advancedFilterFactory->createDropDownFilter(
'is_wfs',
__('WFS'),
$options,
$filterCallback
);

$this->addAdvancedFilter($filter);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ public function execute()
$productType,
$onlyForAttributes
);

$isNewProductType = (bool)$this->getRequest()->getParam('is_new_product_type');
$specificsDefaultSettings = $isNewProductType ? $this->productTypeHelper->getSpecificsDefaultSettings() : [];
$timezoneShift = $this->productTypeHelper->getTimezoneShift();
$specificsDefaultSettings = $this->productTypeHelper->getSpecificsDefaultSettings();
$mainImageSpecifics = $this->productTypeHelper->getMainImageSpecifics();
$otherImagesSpecifics = $this->productTypeHelper->getOtherImagesSpecifics();
$recommendedBrowseNodesLink = $this->productTypeHelper->getRecommendedBrowseNodesLink((int)$marketplaceId);
Expand Down
1 change: 1 addition & 0 deletions Helper/Component/Ebay.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Ebay
public const MARKETPLACE_IT = 10;
public const MARKETPLACE_BE_NL = 11;
public const MARKETPLACE_ES = 13;
public const MARKETPLACE_IN = 16;

public const LISTING_DURATION_GTC = 100;
public const MAX_LENGTH_FOR_OPTION_VALUE = 50;
Expand Down
2 changes: 1 addition & 1 deletion Model/Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function isSingleAccountMode()
return $this->activeRecordFactory->getObject('Account')->getCollection()->getSize() <= 1;
}

//########################################
// ----------------------------------------

public function isCacheEnabled()
{
Expand Down
2 changes: 1 addition & 1 deletion Model/Amazon/Account/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ public function getDefaultData(): array
'shipping_information' => [
'import_labels' => 1,
'ship_by_date' => 1,
'update_without_track' => 1,
'update_without_track' => 0,
'shipping_address_region_override' => 1,
],
],
Expand Down
1 change: 1 addition & 0 deletions Model/Amazon/ProductType/AttributeMapping/Suggester.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private function appendDefaultSuggestedAttributes(array $attributes): array
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_DESCRIPTION => 'description',
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_COUNTRY_OF_ORIGIN => 'country_of_manufacture',
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_ITEM_PACKAGE_WEIGHT => 'weight',
\Ess\M2ePro\Helper\Component\Amazon\ProductType::SPECIFIC_KEY_MAIN_PRODUCT_IMAGE_LOCATOR => 'image',
];

foreach ($map as $productTypeAttributeCode => $magentoAttributeCode) {
Expand Down
74 changes: 57 additions & 17 deletions Model/Cron/Task/Amazon/Order/Receive.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ class Receive extends \Ess\M2ePro\Model\Cron\Task\AbstractModel

/** @var bool */
private $isErrorMessageReceived = false;
/** @var \Ess\M2ePro\Model\Order\SyncStatusManager */
private $syncStatus;

public function __construct(
\Ess\M2ePro\Model\Cron\Manager $cronManager,
\Ess\M2ePro\Helper\Data $helperData,
\Magento\Framework\Event\Manager $eventManager,
\Ess\M2ePro\Model\ActiveRecord\Component\Parent\Factory $parentFactory,
\Ess\M2ePro\Model\Factory $modelFactory,
\Ess\M2ePro\Model\ActiveRecord\Factory $activeRecordFactory,
\Ess\M2ePro\Helper\Factory $helperFactory,
\Ess\M2ePro\Model\Cron\Task\Repository $taskRepo,
\Magento\Framework\App\ResourceConnection $resource,
\Ess\M2ePro\Model\Order\SyncStatusManager $syncStatusManager
) {
parent::__construct(
$cronManager,
$helperData,
$eventManager,
$parentFactory,
$modelFactory,
$activeRecordFactory,
$helperFactory,
$taskRepo,
$resource
);
$this->syncStatusManager = $syncStatusManager;
}

/**
* @return \Ess\M2ePro\Model\Synchronization\Log
Expand All @@ -39,24 +67,36 @@ public function isPossibleToRun()

protected function performActions()
{
$permittedAccounts = $this->getPermittedAccounts();
if (empty($permittedAccounts)) {
return;
}

foreach ($permittedAccounts as $merchantId => $accounts) {
/** @var \Ess\M2ePro\Model\Account $account * */

try {
$this->processAccounts($merchantId, $accounts);
} catch (\Exception $exception) {
$message = $this->getHelper('Module\Translation')->__(
'The "Receive" Action for Amazon Account Merchant "%merchant%" was completed with error.',
$merchantId
);
$isSuccess = true;
try {
$permittedAccounts = $this->getPermittedAccounts();
if (empty($permittedAccounts)) {
return;
}

$this->processTaskAccountException($message, __FILE__, __LINE__);
$this->processTaskException($exception);
foreach ($permittedAccounts as $merchantId => $accounts) {
/** @var \Ess\M2ePro\Model\Account $account * */

try {
$this->processAccounts($merchantId, $accounts);
} catch (\Exception $exception) {
$isSuccess = false;
$message = $this->getHelper('Module\Translation')->__(
'The "Receive" Action for Amazon Account Merchant "%merchant%" was completed with error.',
$merchantId
);

$this->processTaskAccountException($message, __FILE__, __LINE__);
$this->processTaskException($exception);
}
}
} catch (\Throwable $e) {
throw $e;
} finally {
if (isset($e) || !$isSuccess) {
$this->syncStatusManager->setLastRunAsFail(\Ess\M2ePro\Helper\Component\Amazon::NICK);
} else {
$this->syncStatusManager->setLastRunAsSuccess(\Ess\M2ePro\Helper\Component\Amazon::NICK);
}
}
}
Expand Down
5 changes: 0 additions & 5 deletions Model/Cron/Task/Ebay/Channel/SynchronizeChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class SynchronizeChanges extends \Ess\M2ePro\Model\Cron\Task\AbstractModel
*/
protected $interval = 300;

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

/**
* @return \Ess\M2ePro\Model\Synchronization\Log
*/
Expand All @@ -47,7 +45,6 @@ protected function processItemsChanges()
{
/** @var \Ess\M2ePro\Model\Cron\Task\Ebay\Channel\SynchronizeChanges\ItemsProcessor $itemsProcessor */
$itemsProcessor = $this->modelFactory->getObject('Cron_Task_Ebay_Channel_SynchronizeChanges_ItemsProcessor');

$synchronizationLog = $this->getSynchronizationLog();
$synchronizationLog->setSynchronizationTask(\Ess\M2ePro\Model\Synchronization\Log::TASK_OTHER);

Expand Down Expand Up @@ -78,6 +75,4 @@ protected function processOrdersChanges()

$ordersProcessor->process();
}

//########################################
}
Loading

0 comments on commit 7144027

Please sign in to comment.