Skip to content

Commit

Permalink
1.68.1 (FINAL RELEASE)
Browse files Browse the repository at this point in the history
  • Loading branch information
m2epro committed Oct 15, 2024
1 parent 497bf25 commit a4f3152
Show file tree
Hide file tree
Showing 26 changed files with 183 additions and 190 deletions.
6 changes: 3 additions & 3 deletions Controller/Adminhtml/Walmart/Listing/Product/Add/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ private function review(\Ess\M2ePro\Model\Marketplace $marketplace): void
return;
}

if (!$marketplace->getChildObject()->isCanada()) {
$this->removeFailedProducts($additionalData['adding_listing_products_ids']);
if ($marketplace->getChildObject()->isSupportedProductType()) {
$this->removeProductsWithoutProductTypes($additionalData['adding_listing_products_ids']);
}

//-- Remove successfully moved Unmanaged items
Expand Down Expand Up @@ -349,7 +349,7 @@ private function review(\Ess\M2ePro\Model\Marketplace $marketplace): void
$this->addContent($blockReview);
}

private function removeFailedProducts(array $addingListingProductsIds): void
private function removeProductsWithoutProductTypes(array $addingListingProductsIds): void
{
/** @var \Ess\M2ePro\Model\ResourceModel\Listing\Product\Collection $collection */
$collection = $this->listingProductCollectionFactory
Expand Down
21 changes: 7 additions & 14 deletions Model/Ebay/Listing/Product/Action/DataBuilder/Description.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
<?php

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

namespace Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataBuilder;

/**
* Class \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataBuilder\Description
*/
class Description extends AbstractModel
{
//########################################

public function getBuilderData()
public function getBuilderData(): array
{
$this->searchNotFoundAttributes();

Expand All @@ -24,10 +13,14 @@ public function getBuilderData()

$this->processNotFoundAttributes('Description');

$descriptionTemplate = $this->getEbayListingProduct()->getEbayDescriptionTemplate();

return [
'description' => $data,
'product_details' => [
'include_ebay_details' => $descriptionTemplate->isProductDetailsIncludeEbayDetails(),
'include_image' => $descriptionTemplate->isProductDetailsIncludeImage(),
],
];
}

//########################################
}
12 changes: 1 addition & 11 deletions Model/Ebay/Listing/Product/Action/DataBuilder/General.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,10 @@ private function getProductDetailsData(): array
return [];
}

$data = array_merge(
return array_merge(
$this->getProductsIdentifiersData(),
$this->getMPNAndBrandData()
);

if (empty($data)) {
return $data;
}

$template = $this->getEbayListingProduct()->getEbayDescriptionTemplate();
$data['include_ebay_details'] = $template->isProductDetailsIncludeEbayDetails();
$data['include_image'] = $template->isProductDetailsIncludeImage();

return $data;
}

private function getProductsIdentifiersData(): array
Expand Down
9 changes: 6 additions & 3 deletions Model/Ebay/Listing/Product/Action/DataHasher.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

class DataHasher
{
/** @var \Ess\M2ePro\Helper\Data */
private $dataHelper;
private \Ess\M2ePro\Helper\Data $dataHelper;

public function __construct(\Ess\M2ePro\Helper\Data $dataHelper)
{
Expand All @@ -18,13 +17,17 @@ public function hashProductIdentifiers(
string $upc = null,
string $ean = null,
string $isbn = null,
string $epid = null
string $epid = null,
string $brand = null,
string $mpn = null
): string {
$productIdentifiers = [
'upc' => $upc,
'ean' => $ean,
'isbn' => $isbn,
'epid' => $epid,
'brand' => $brand,
'mpn' => $mpn,
];

return $this->dataHelper->md5String(
Expand Down
31 changes: 31 additions & 0 deletions Model/Ebay/Listing/Product/Action/DescriptionHasher.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Ess\M2ePro\Model\Ebay\Listing\Product\Action;

class DescriptionHasher
{
private \Ess\M2ePro\Helper\Data $dataHelper;

public function __construct(\Ess\M2ePro\Helper\Data $dataHelper)
{
$this->dataHelper = $dataHelper;
}

public function hashProductDescriptionFields(
string $description = null,
string $includeEbayDetails = null,
string $includeImage = null
): string {
$productDescriptionFields = [
'description' => $description,
'include_ebay_details' => $includeEbayDetails,
'include_image' => $includeImage,
];

return $this->dataHelper->md5String(
\Ess\M2ePro\Helper\Json::encode($productDescriptionFields)
);
}
}
20 changes: 20 additions & 0 deletions Model/Ebay/Listing/Product/Action/RequestData.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,16 @@ public function getDescription()
return $this->hasDescription() ? $this->getData()['description'] : null;
}

public function getProductDetailsIncludeEbayDetails(): ?string
{
return $this->getProductDetails()['include_ebay_details'] ?? null;
}

public function getProductDetailsIncludeImage(): ?string
{
return $this->getProductDetails()['include_image'] ?? null;
}

// ---------------------------------------

public function getDuration()
Expand Down Expand Up @@ -258,6 +268,16 @@ public function getProductDetailsIsbn(): ?string
return $this->getProductDetails()['isbn'] ?? null;
}

public function getProductDetailsBrand(): ?string
{
return $this->getProductDetails()['brand'] ?? null;
}

public function getProductDetailsMpn(): ?string
{
return $this->getProductDetails()['mpn'] ?? null;
}

// ---------------------------------------

public function getVariations()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Response extends \Ess\M2ePro\Model\Ebay\Listing\Product\Action\Type\Respon
private RemoveEpcHostedImagesWithWatermarkService $removeEpcHostedImagesWithWatermark;

public function __construct(
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher,
\Ess\M2ePro\Model\Ebay\Video\ProductProcessor $videoProductProcessor,
RemoveEpcHostedImagesWithWatermarkService $removeEpcHostedImagesWithWatermark,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher $dataHasher,
Expand All @@ -19,6 +20,7 @@ public function __construct(
\Ess\M2ePro\Model\Factory $modelFactory
) {
parent::__construct(
$descriptionHasher,
$dataHasher,
$componentEbayCategoryEbay,
$activeRecordFactory,
Expand Down
2 changes: 2 additions & 0 deletions Model/Ebay/Listing/Product/Action/Type/Relist/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class Response extends \Ess\M2ePro\Model\Ebay\Listing\Product\Action\Type\Respon
private \Ess\M2ePro\Model\Ebay\Video\ProductProcessor $videoProductProcessor;

public function __construct(
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher,
\Ess\M2ePro\Model\Ebay\Video\ProductProcessor $videoProductProcessor,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher $dataHasher,
\Ess\M2ePro\Helper\Component\Ebay\Category\Ebay $componentEbayCategoryEbay,
Expand All @@ -27,6 +28,7 @@ public function __construct(
\Ess\M2ePro\Model\Factory $modelFactory
) {
parent::__construct(
$descriptionHasher,
$dataHasher,
$componentEbayCategoryEbay,
$activeRecordFactory,
Expand Down
23 changes: 14 additions & 9 deletions Model/Ebay/Listing/Product/Action/Type/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ abstract class Response extends \Ess\M2ePro\Model\AbstractModel
protected $requestMetaData = [];
protected $activeRecordFactory;

private \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher;
/** @var \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher */
private $dataHasher;
/** @var \Ess\M2ePro\Model\Listing\Product */
Expand All @@ -28,6 +29,7 @@ abstract class Response extends \Ess\M2ePro\Model\AbstractModel
private $componentEbayCategoryEbay;

public function __construct(
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher $dataHasher,
\Ess\M2ePro\Helper\Component\Ebay\Category\Ebay $componentEbayCategoryEbay,
\Ess\M2ePro\Model\ActiveRecord\Factory $activeRecordFactory,
Expand All @@ -36,6 +38,7 @@ public function __construct(
) {
parent::__construct($helperFactory, $modelFactory);

$this->descriptionHasher = $descriptionHasher;
$this->dataHasher = $dataHasher;
$this->activeRecordFactory = $activeRecordFactory;
$this->componentEbayCategoryEbay = $componentEbayCategoryEbay;
Expand Down Expand Up @@ -571,17 +574,17 @@ protected function appendIsAuctionType(array $data)
return $data;
}

protected function appendDescriptionValues($data)
protected function appendDescriptionValues($data): array
{
if (!$this->getRequestData()->hasDescription()) {
return $data;
}

$data['online_description'] = $this->getHelper('Data')->hashString(
$this->getRequestData()->getDescription(),
'md5'
$requestData = $this->getRequestData();
$hash = $this->descriptionHasher->hashProductDescriptionFields(
$requestData->getDescription(),
$requestData->getProductDetailsIncludeEbayDetails(),
$requestData->getProductDetailsIncludeImage()
);

$data[\Ess\M2ePro\Model\ResourceModel\Ebay\Listing\Product::COLUMN_ONLINE_DESCRIPTION] = $hash;

return $data;
}

Expand All @@ -607,7 +610,9 @@ protected function appendProductIdentifiersValues(array $data): array
$requestData->getProductDetailsUpc(),
$requestData->getProductDetailsEan(),
$requestData->getProductDetailsIsbn(),
$requestData->getProductDetailsEpid()
$requestData->getProductDetailsEpid(),
$requestData->getProductDetailsBrand(),
$requestData->getProductDetailsMpn()
);

$data[\Ess\M2ePro\Model\ResourceModel\Ebay\Listing\Product::COLUMN_ONLINE_PRODUCT_IDENTIFIERS_HASH] = $hash;
Expand Down
19 changes: 16 additions & 3 deletions Model/Ebay/Listing/Product/Action/Type/Revise/Checker.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

class Checker
{
private \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher;
/** @var \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher */
private $dataHasher;
/** @var \Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataBuilder\TitleFactory */
Expand Down Expand Up @@ -34,6 +35,7 @@ class Checker
private $configuratorFactory;

public function __construct(
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher $dataHasher,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\ConfiguratorFactory $configuratorFactory,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataBuilder\TitleFactory $titleDataBuilderFactory,
Expand Down Expand Up @@ -63,6 +65,7 @@ public function __construct(
$this->helperData = $helperData;
$this->configuratorFactory = $configuratorFactory;
$this->dataHasher = $dataHasher;
$this->descriptionHasher = $descriptionHasher;
}

public function calculateForManualAction(\Ess\M2ePro\Model\Listing\Product $listingProduct): Checker\Result
Expand Down Expand Up @@ -327,9 +330,13 @@ public function isNeedReviseForDescription(\Ess\M2ePro\Model\Ebay\Listing\Produc

$actionData = $actionDataBuilder->getBuilderData();

$hashDescription = $this->helperData->md5String($actionData['description']);
$hash = $this->descriptionHasher->hashProductDescriptionFields(
$actionData['description'] ?? null,
$actionData['product_details']['include_ebay_details'] ?? null,
$actionData['product_details']['include_image'] ?? null
);

return $hashDescription !== $ebayListingProduct->getOnlineDescription();
return $hash !== $ebayListingProduct->getOnlineDescription();
}

/**
Expand Down Expand Up @@ -364,6 +371,10 @@ public function isNeedReviseForProductIdentifiers(\Ess\M2ePro\Model\Ebay\Listing
return false;
}

if ($ebayListingProduct->getSku() !== $ebayListingProduct->getOnlineSku()) {
return true;
}

$generalDataBuilder = $this->generalDataBuilderFactory->create(
$ebayListingProduct->getParentObject()
);
Expand All @@ -379,7 +390,9 @@ public function isNeedReviseForProductIdentifiers(\Ess\M2ePro\Model\Ebay\Listing
$productDetails['upc'] ?? null,
$productDetails['ean'] ?? null,
$productDetails['isbn'] ?? null,
$productDetails['epid'] ?? null
$productDetails['epid'] ?? null,
$productDetails['brand'] ?? null,
$productDetails['mpn'] ?? null
);

return $hash !== $ebayListingProduct->getOnlineProductIdentifiersHash();
Expand Down
8 changes: 6 additions & 2 deletions Model/Ebay/Listing/Product/Action/Type/Revise/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,20 @@ public function getActionData(): array
{
$generalData = $this->getGeneralData();
$otherData = $this->getOtherData();
$descriptionData = $this->getDescriptionData();

if (
isset($generalData['product_details'])
|| isset($otherData['product_details'])
|| isset($descriptionData['product_details'])
) {
$otherData['product_details'] = array_merge(
$otherData['product_details'] ?? [],
$generalData['product_details'] ?? []
$generalData['product_details'] ?? [],
$descriptionData['product_details'] ?? []
);
unset($generalData['product_details']);
unset($descriptionData['product_details']);
}

$data = array_merge(
Expand All @@ -29,7 +33,7 @@ public function getActionData(): array
$this->getPriceData(),
$this->getTitleData(),
$this->getSubtitleData(),
$this->getDescriptionData(),
$descriptionData,
$this->getImagesData(),
$this->getCategoriesData(),
$this->getPartsData(),
Expand Down
2 changes: 2 additions & 0 deletions Model/Ebay/Listing/Product/Action/Type/Revise/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ class Response extends \Ess\M2ePro\Model\Ebay\Listing\Product\Action\Type\Respon
private RemoveEpcHostedImagesWithWatermarkService $removeEpcHostedImagesWithWatermark;

public function __construct(
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DescriptionHasher $descriptionHasher,
RemoveEpcHostedImagesWithWatermarkService $removeEpcHostedImagesWithWatermark,
\Ess\M2ePro\Model\Ebay\Listing\Product\Action\DataHasher $dataHasher,
\Ess\M2ePro\Helper\Component\Ebay\Category\Ebay $componentEbayCategoryEbay,
Expand All @@ -17,6 +18,7 @@ public function __construct(
\Ess\M2ePro\Model\Factory $modelFactory
) {
parent::__construct(
$descriptionHasher,
$dataHasher,
$componentEbayCategoryEbay,
$activeRecordFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ protected function getReviseVariationImagesInstructionTypes(): array
protected function getReviseProductIdentifiersInstructionsTypes(): array
{
return [
ChangeProcessorAbstract::INSTRUCTION_TYPE_PRODUCT_DATA_POTENTIALLY_CHANGED,
\Ess\M2ePro\Model\Ebay\Magento\Product\ChangeProcessor::INSTRUCTION_TYPE_PRODUCT_IDENTIFIERS_DATA_CHANGED,
ChangeIdentifierTracker::INSTRUCTION_TYPE_PRODUCT_IDENTIFIER_CONFIG_CHANGED,
SynchronizationChangeProcessor::INSTRUCTION_TYPE_REVISE_PRODUCT_IDENTIFIERS_ENABLED,
Expand Down
Loading

0 comments on commit a4f3152

Please sign in to comment.