Skip to content

Commit

Permalink
1.66.2 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Sep 2, 2024
1 parent 23e458f commit c8b305d
Show file tree
Hide file tree
Showing 52 changed files with 503 additions and 388 deletions.
17 changes: 4 additions & 13 deletions Block/Adminhtml/Amazon/Listing/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,10 @@

class View extends \Ess\M2ePro\Block\Adminhtml\Magento\Grid\AbstractContainer
{
/** @var \Ess\M2ePro\Model\Listing */
protected $listing;
/** @var \Ess\M2ePro\Helper\Data */
private $dataHelper;
/** @var \Ess\M2ePro\Helper\Data\GlobalData */
private $globalDataHelper;
/** @var \Ess\M2ePro\Helper\Data\Session */
private $sessionDataHelper;
protected \Ess\M2ePro\Model\Listing $listing;
private \Ess\M2ePro\Helper\Data $dataHelper;
private \Ess\M2ePro\Helper\Data\GlobalData $globalDataHelper;
private \Ess\M2ePro\Helper\Data\Session $sessionDataHelper;

public function __construct(
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Widget $context,
Expand Down Expand Up @@ -63,11 +59,6 @@ protected function _prepareLayout()
available Actions accessible in the Mass Actions drop-down.</p>'
),
]);

$this->setPageActionsBlock(
'Amazon_Listing_View_Switcher',
'amazon_listing_view_switcher'
);
}

// ---------------------------------------
Expand Down
9 changes: 0 additions & 9 deletions Block/Adminhtml/Amazon/Template/ProductType/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,15 +111,6 @@ public function _construct()

$isSaveAndClose = (bool)$this->getRequest()->getParam('close_on_save', false);

//$this->addButton(
// 'view_mode_switch_button',
// [
// 'class_name' => \Ess\M2ePro\Block\Adminhtml\Magento\Button\ProductTypeSwitchButton::class,
// 'label' => $this->__('Only Required Attributes'),
// 'value' => $this->productType->getViewMode(),
// ]
//);

if (!$isSaveAndClose && $this->isEditMode()) {
$this->buttonList->add(
'delete',
Expand Down
30 changes: 0 additions & 30 deletions Block/Adminhtml/Ebay/Listing/Switcher.php

This file was deleted.

20 changes: 3 additions & 17 deletions Block/Adminhtml/Ebay/Listing/View.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,14 @@
<?php

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

namespace Ess\M2ePro\Block\Adminhtml\Ebay\Listing;

use Ess\M2ePro\Block\Adminhtml\Magento\Grid\AbstractContainer;

class View extends AbstractContainer
{
/** @var \Ess\M2ePro\Model\Listing */
private $listing;
/** @var \Ess\M2ePro\Helper\Data */
private $dataHelper;
/** @var \Ess\M2ePro\Helper\Data\GlobalData */
private $globalDataHelper;
private \Ess\M2ePro\Model\Listing $listing;
private \Ess\M2ePro\Helper\Data $dataHelper;
private \Ess\M2ePro\Helper\Data\GlobalData $globalDataHelper;

public function __construct(
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Widget $context,
Expand Down Expand Up @@ -77,11 +68,6 @@ protected function _prepareLayout()
),
]
);

$this->setPageActionsBlock(
'Ebay_Listing_View_Switcher',
'ebay_listing_view_switcher'
);
}

// ---------------------------------------
Expand Down
91 changes: 74 additions & 17 deletions Block/Adminhtml/Listing/Switcher.php
Original file line number Diff line number Diff line change
@@ -1,30 +1,87 @@
<?php

/**
* @author M2E Pro Developers Team
* @copyright M2E LTD
* @license Commercial use is forbidden
*/
declare(strict_types=1);

namespace Ess\M2ePro\Block\Adminhtml\Listing;

use Ess\M2ePro\Block\Adminhtml\Magento\AbstractBlock;

/**
* Class \Ess\M2ePro\Block\Adminhtml\Listing\Switcher
*/
abstract class Switcher extends AbstractBlock
class Switcher extends \Ess\M2ePro\Block\Adminhtml\Switcher
{
//########################################
protected $paramName = 'id';
private \Ess\M2ePro\Model\Amazon\Listing\Repository $amazonListingRepository;
private \Ess\M2ePro\Model\Ebay\Listing\Repository $ebayListingRepository;
private \Ess\M2ePro\Model\Walmart\Listing\Repository $walmartListingRepository;
private string $componentMode;

public function __construct(
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Template $context,
\Ess\M2ePro\Model\Amazon\Listing\Repository $amazonListingRepository,
\Ess\M2ePro\Model\Ebay\Listing\Repository $ebayListingRepository,
\Ess\M2ePro\Model\Walmart\Listing\Repository $walmartListingRepository,
array $data = []
) {
parent::__construct($context, $data);
$this->amazonListingRepository = $amazonListingRepository;
$this->ebayListingRepository = $ebayListingRepository;
$this->walmartListingRepository = $walmartListingRepository;
$this->componentMode = $data['component_mode'] ?? '';
}

public function getLabel(): string
{
return (string)__('View Listing:');
}

public function _construct()
public function hasDefaultOption(): bool
{
parent::_construct();
return false;
}

$this->setAddListingUrl('');
protected function loadItems(): void
{
$listings = $this->getListingCollection();

$this->setTemplate('Ess_M2ePro::listing/switcher.phtml');
if (empty($listings)) {
$this->items = [];

return;
}

if (count($listings) < 2) {
$this->hasDefaultOption = false;
$this->setIsDisabled(true);
}

$items = [];
foreach ($listings as $listing) {
$listingTitle = $this->filterManager->truncate(
$listing->getTitle(),
['length' => 70]
);

$items[] = [
'value' => $listing->getId(),
'label' => $listingTitle,
];
}

$this->items = ['mode' => ['value' => $items]];
}

//########################################
/**
* @return \Ess\M2ePro\Model\Listing[]
* @throws \Ess\M2ePro\Model\Exception\Logic
*/
private function getListingCollection(): array
{
switch ($this->componentMode) {
case \Ess\M2ePro\Helper\Component\Amazon::NICK:
return $this->amazonListingRepository->getAll();
case \Ess\M2ePro\Helper\Component\Ebay::NICK:
return $this->ebayListingRepository->getAll();
case \Ess\M2ePro\Helper\Component\Walmart::NICK:
return $this->walmartListingRepository->getAll();
default:
throw new \Ess\M2ePro\Model\Exception\Logic('Invalid component mode: ' . $this->componentMode);
}
}
}
23 changes: 4 additions & 19 deletions Block/Adminhtml/Walmart/Listing/View.php
Original file line number Diff line number Diff line change
@@ -1,25 +1,15 @@
<?php

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

namespace Ess\M2ePro\Block\Adminhtml\Walmart\Listing;

use Ess\M2ePro\Block\Adminhtml\Log\Listing\Product\AbstractGrid;

class View extends \Ess\M2ePro\Block\Adminhtml\Magento\Grid\AbstractContainer
{
/** @var \Ess\M2ePro\Model\Listing */
protected $listing;
/** @var \Ess\M2ePro\Helper\Data */
private $dataHelper;
/** @var \Ess\M2ePro\Helper\Data\GlobalData */
private $globalDataHelper;
/** @var \Ess\M2ePro\Helper\Data\Session */
private $sessionDataHelper;
protected \Ess\M2ePro\Model\Listing $listing;
private \Ess\M2ePro\Helper\Data $dataHelper;
private \Ess\M2ePro\Helper\Data\GlobalData $globalDataHelper;
private \Ess\M2ePro\Helper\Data\Session $sessionDataHelper;

public function __construct(
\Ess\M2ePro\Block\Adminhtml\Magento\Context\Widget $context,
Expand Down Expand Up @@ -68,11 +58,6 @@ protected function _prepareLayout()
),
]
);

$this->setPageActionsBlock(
'Walmart_Listing_View_Switcher',
'walmart_listing_view_switcher'
);
}

$this->addButton(
Expand Down
38 changes: 0 additions & 38 deletions Helper/Component/Ebay/BlockingErrorConfig.php

This file was deleted.

5 changes: 4 additions & 1 deletion Model/Amazon/Connector/Orders/Refund/ItemsRequester.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,11 @@ public function getRequestData()
'order_id' => $this->params['order']['amazon_order_id'],
'currency' => $this->params['order']['currency'],
'type' => 'Refund',
'adjustment_fee' => $this->params['order']['adjustment_fee'] ?? 0,
'adjustment_refund' => $this->params['order']['adjustment_refund'] ?? 0,
'shipping_refund' => $this->params['order']['shipping_refund'] ?? 0,
'shipping_tax_refund' => $this->params['order']['shipping_tax_refund'] ?? 0,
'items' => $this->params['order']['items'],
'adjustment_fee' => $this->params['order']['adjustment_fee'] ?? null,
];
}

Expand Down
2 changes: 1 addition & 1 deletion Model/Amazon/Connector/Protocol.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class Protocol implements \Ess\M2ePro\Model\Connector\ProtocolInterface
{
public const COMPONENT_VERSION = 21;
public const COMPONENT_VERSION = 22;

/**
* @return string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public function processSuccess(array $params = []): void

$this->setVariationData($generalId);

$this->getListingProduct()->removeBlockingByError();

$this->getListingProduct()->save();

if (!$variationManager->isRelationParentType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,8 +325,9 @@ private function recognizeBySearchWorldwideId()

$this->addMessage(
$this->log->encodeDescription(
'%worldwide_id_type% %worldwide_id% provided in Main Settings
is not found on Amazon. Please set Product Type to create New ASIN/ISBN.',
'No ASIN found for the %worldwide_id_type% %worldwide_id% provided in the Main Settings.
Ensure that creation of new ASIN/ISBN is enabled and that a valid Product Type
is assigned to the Listing Product.',
['!worldwide_id_type' => $worldwideIdType, '!worldwide_id' => $worldwideId->getIdentifier()]
)
);
Expand Down
2 changes: 2 additions & 0 deletions Model/Amazon/Listing/Product/Action/Type/Relist/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function processSuccess(array $params = []): void
$this->getAmazonListingProduct()->addData($data);
$this->getAmazonListingProduct()->setIsStoppedManually(false);

$this->getListingProduct()->removeBlockingByError();

$this->setLastSynchronizationDates();

$this->getListingProduct()->save();
Expand Down
2 changes: 2 additions & 0 deletions Model/Amazon/Listing/Product/Action/Type/Revise/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ public function processSuccess(array $params = []): void
$this->getAmazonListingProduct()->addData($data);
$this->getAmazonListingProduct()->setIsStoppedManually(false);

$this->getListingProduct()->removeBlockingByError();

$this->setLastSynchronizationDates();

$this->getListingProduct()->save();
Expand Down
26 changes: 26 additions & 0 deletions Model/Amazon/Listing/Repository.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace Ess\M2ePro\Model\Amazon\Listing;

class Repository
{
private \Ess\M2ePro\Model\ResourceModel\Listing\CollectionFactory $listingCollectionFactory;

public function __construct(
\Ess\M2ePro\Model\ResourceModel\Listing\CollectionFactory $listingCollectionFactory
) {
$this->listingCollectionFactory = $listingCollectionFactory;
}

/**
* @return \Ess\M2ePro\Model\Listing[]
*/
public function getAll(): array
{
$listingsCollection = $this->listingCollectionFactory->createWithAmazonChildMode();

return array_values($listingsCollection->getItems());
}
}
Loading

0 comments on commit c8b305d

Please sign in to comment.