Skip to content

Commit

Permalink
Releasing v1.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
vlmed committed Dec 2, 2024
1 parent e4cf0f2 commit 2be9fa4
Show file tree
Hide file tree
Showing 68 changed files with 4,402 additions and 491 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/magento-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ env:
DB_USER: root
DB_PASSWORD: root
ES_VERSION: 7.10.0
PHP_VERSION: 8.1
PHP_VERSION: 8.3


on: [pull_request]
Expand All @@ -23,7 +23,7 @@ jobs:
uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php
with:
php-version: ${{ env.PHP_VERSION }}
tools: composer:2.2.17
tools: composer
extensions: mbstring, gd, bcmath, soap, dom, xml, json, tokenizer, mysql, zip, xdebug

# Use composer cache
Expand Down
43 changes: 41 additions & 2 deletions Block/Adminhtml/InitialImport/CurrentProgress.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use Bloomreach\EngagementConnector\Model\Export\Queue\AddInitialExportDataToExportQueue;
use Bloomreach\EngagementConnector\Model\Export\Queue\Source\StatusSource as ExportQueueStatusSource;
use Bloomreach\EngagementConnector\Model\ExportQueueModel;
use Bloomreach\EngagementConnector\Model\InitialExportStatus\Source\StatusSource as InitialExportStatusSource;
use Bloomreach\EngagementConnector\Model\InitialExportStatus\Source\StatusSource;
use Bloomreach\EngagementConnector\Model\ResourceModel\ExportQueue\Collection as ExportQueueCollection;
use Bloomreach\EngagementConnector\Model\ResourceModel\ExportQueue\CollectionFactory as ExportQueueCollectionFactory;
use Bloomreach\EngagementConnector\Service\InitialExportStatus\ItemGetter as InitialExportStatusGetter;
Expand Down Expand Up @@ -180,7 +180,10 @@ public function getExportQueueCollection(): ExportQueueCollection
*/
public function isStarted(): bool
{
return $this->getInitialExportStatus()->getStatus() === InitialExportStatusSource::PROCESSING;
return in_array(
$this->getInitialExportStatus()->getStatus(),
StatusSource::PROGRESS_LOG_VISIBLE_STATUSES
);
}

/**
Expand Down Expand Up @@ -307,6 +310,42 @@ public function getDecoratedStatus(ExportQueueInterface $exportQueue): string
);
}

/**
* Checks whether import is finished
*
* @return bool
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function isFinished(): bool
{
return in_array($this->getInitialExportStatus()->getStatus(), StatusSource::FINISHED_STATUSES);
}

/**
* Get total error items
*
* @return int
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function getTotalErrorItems(): int
{
return $this->getInitialExportStatus()->getTotalErrorItems();
}

/**
* Get total exported items
*
* @return int
* @throws LocalizedException
* @throws NoSuchEntityException
*/
public function getTotalExportedItems(): int
{
return $this->getInitialExportStatus()->getTotalExported();
}

/**
* Set template
*
Expand Down
54 changes: 54 additions & 0 deletions Model/Config/Backend/ValidateSearchableFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?php
/**
* @author Bloomreach
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/)
*/
declare(strict_types=1);

namespace Bloomreach\EngagementConnector\Model\Config\Backend;

use Bloomreach\EngagementConnector\Model\InitialExport\Action\Configure\Catalog\FieldsMapper;
use Magento\Framework\App\Config\Value;
use Magento\Framework\Exception\LocalizedException;

/**
* Allows select up to 20 options
*/
class ValidateSearchableFields extends Value
{
/**
* Checks for unique options.
*
* @return $this
* @throws LocalizedException
*/
public function beforeSave()
{
if ($this->getFieldsetDataValue('enabled') !== '1') {
return parent::beforeSave();
}

$value = $this->getValue();

if (!$value) {
throw new LocalizedException(
__(
'Searchable fields cannot be empty.',
FieldsMapper::MAX_SEARCHABLE
)
);
}

if (count($value) <= FieldsMapper::MAX_SEARCHABLE) {
return parent::beforeSave();

}

throw new LocalizedException(
__(
'Maximum number of searchable fields exceeded. Max number: "%1"',
FieldsMapper::MAX_SEARCHABLE
)
);
}
}
67 changes: 67 additions & 0 deletions Model/Config/Source/CatalogProductFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?php
/**
* @author Bloomreach
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/)
*/
declare(strict_types=1);

namespace Bloomreach\EngagementConnector\Model\Config\Source;

use Bloomreach\EngagementConnector\Model\DataMapping\ConfigResolver;
use Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\Product\DefaultType;
use Bloomreach\EngagementConnector\Model\InitialExport\Action\Configure\Catalog\FieldsMapper;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Framework\Exception\NotFoundException;

/**
* 'catalog_product' fields source
*/
class CatalogProductFields implements OptionSourceInterface
{
/**
* @var ConfigResolver
*/
private $configResolver;

/**
* @param ConfigResolver $configResolver
*/
public function __construct(ConfigResolver $configResolver)
{
$this->configResolver = $configResolver;
}

/**
* Get options
*
* @return array
* @throws NotFoundException
*/
public function toOptionArray()
{
$options = [];

foreach ($this->configResolver->getByEntityType($this->getEntityType()) as $item) {
if ($item->getBloomreachCode() === FieldsMapper::PRIMARY_ID) {
continue;
}

$options[] = [
'label' => $item->getBloomreachCode(),
'value' => $item->getBloomreachCode()
];
}

return $options;
}

/**
* Get entity type
*
* @return string
*/
protected function getEntityType(): string
{
return DefaultType::ENTITY_TYPE;
}
}
30 changes: 30 additions & 0 deletions Model/Config/Source/CatalogProductVariantsFields.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @author Bloomreach
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/)
*/
declare(strict_types=1);

namespace Bloomreach\EngagementConnector\Model\Config\Source;

use Bloomreach\EngagementConnector\Model\DataMapping\ConfigResolver;
use Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\Product\DefaultType;
use Bloomreach\EngagementConnector\Model\DataMapping\DataMapper\Product\ProductVariantsType;
use Magento\Framework\Data\OptionSourceInterface;
use Magento\Framework\Exception\NotFoundException;

/**
* 'catalog_product_variants' fields source
*/
class CatalogProductVariantsFields extends CatalogProductFields
{
/**
* Get entity type
*
* @return string
*/
protected function getEntityType(): string
{
return ProductVariantsType::ENTITY_TYPE;
}
}
30 changes: 30 additions & 0 deletions Model/DataMapping/FieldValueRenderer/DefaultFloatValueRenderer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @author Bloomreach
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/)
*/
declare(strict_types=1);

namespace Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer;

use Magento\Framework\Api\AbstractSimpleObject;
use Magento\Framework\Model\AbstractModel;

/**
* The class is responsible for rendering float value field
*/
class DefaultFloatValueRenderer implements RenderInterface
{
/**
* Render the value of float field
*
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return float
*/
public function render($entity, string $fieldCode)
{
return round((float) $entity->getData($fieldCode), 2);
}
}
21 changes: 4 additions & 17 deletions Model/DataMapping/FieldValueRenderer/Order/FloatValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,12 @@

namespace Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\Order;

use Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\RenderInterface;
use Magento\Framework\Api\AbstractSimpleObject;
use Magento\Framework\Model\AbstractModel;
use Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\DefaultFloatValueRenderer;

/**
* The class is responsible for rendering float value field
* @deprecated
* @see DefaultFloatValueRenderer
*/
class FloatValue implements RenderInterface
class FloatValue extends DefaultFloatValueRenderer
{
/**
* Render the value of float field
*
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return string
*/
public function render($entity, string $fieldCode)
{
return number_format(round((float) $entity->getData($fieldCode), 2), 4, '.', '');
}
}
2 changes: 1 addition & 1 deletion Model/DataMapping/FieldValueRenderer/Order/VariantList.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private function getItemData(OrderItemInterface $orderItem): array
return [
'variant_id' => $productId,
'sku' => $orderItem->getSku(),
'quantity' => $orderItem->getQtyOrdered()
'quantity' => (int) $orderItem->getQtyOrdered()
];
}
}
12 changes: 4 additions & 8 deletions Model/DataMapping/FieldValueRenderer/OrderItem/OriginalPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,13 @@ public function __construct(GetChildItems $getChildItems)
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return string
* @return float
*/
public function render($entity, string $fieldCode)
{
$price = $this->roundPrice((float) $entity->getData($fieldCode));

if ($entity->getProductType() === BundleType::TYPE_CODE) {
$price = $this->getBundleProductPrice($entity, $fieldCode);
}

return number_format($price, 2, ',', '');
return $entity->getProductType() === BundleType::TYPE_CODE
? $this->getBundleProductPrice($entity, $fieldCode)
: $this->roundPrice((float) $entity->getData($fieldCode));
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Model/DataMapping/FieldValueRenderer/Product/Discount.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ public function __construct(GetDiscountService $getDiscountService)
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return string
* @return float
*/
public function render($entity, string $fieldCode)
{
return number_format($this->getDiscountService->execute($entity), 2, '.', '');
return $this->getDiscountService->execute($entity);
}
}
4 changes: 2 additions & 2 deletions Model/DataMapping/FieldValueRenderer/Product/FinalPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ class FinalPrice implements RenderInterface
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return string
* @return float
*/
public function render($entity, string $fieldCode)
{
return number_format(round((float) $entity->getFinalPrice(), 2), 4, '.', '');
return round((float) $entity->getFinalPrice(), 2);
}
}
30 changes: 30 additions & 0 deletions Model/DataMapping/FieldValueRenderer/Product/FloatValue.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
/**
* @author Bloomreach
* @copyright Copyright (c) Bloomreach (https://www.bloomreach.com/)
*/
declare(strict_types=1);

namespace Bloomreach\EngagementConnector\Model\DataMapping\FieldValueRenderer\Product;

use Magento\Framework\Api\AbstractSimpleObject;
use Magento\Framework\Model\AbstractModel;

/**
* The class is responsible for rendering the value of product field
*/
class FloatValue extends DefaultRenderer
{
/**
* Render the value of product field and convert to float
*
* @param AbstractSimpleObject|AbstractModel $entity
* @param string $fieldCode
*
* @return float
*/
public function render($entity, string $fieldCode)
{
return (float) parent::render($entity, $fieldCode);
}
}
6 changes: 2 additions & 4 deletions Model/DataMapping/FieldValueRenderer/Quote/TotalPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,9 @@ public function render($entity, string $fieldCode)
{
$quoteTotals = $this->getQuoteTotals->execute($entity);

return number_format(
return (float) round(
(float) ($quoteTotals ? $quoteTotals->getBaseGrandTotal() : $entity->getBaseGrandTotal()),
2,
',',
''
2
);
}
}
Loading

0 comments on commit 2be9fa4

Please sign in to comment.