Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADS-4303 Support export for all configured languages #8

Merged
merged 5 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/Model/Nosto/Entity/Order/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public function build(OrderEntity $order, Context $context): NostoOrder
$orderCreated = $order->getCreatedAt()->format('Y-m-d H:i:s');
$nostoOrder->setCreatedAt($orderCreated);
if ($order->getTransactions() instanceof OrderTransactionCollection) {
$nostoOrder->setPaymentProvider((string) $order->getTransactions()->first()->getPaymentMethod()->getName());
$nostoOrder->setPaymentProvider(
(string) $order->getTransactions()?->first()?->getPaymentMethod()?->getTranslation('name'),
);
} else {
throw new NostoException('Order has no payment associated');
}
Expand Down
2 changes: 1 addition & 1 deletion src/Model/Nosto/Entity/Order/Status/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function build(OrderEntity $order): ?NostoOrderStatus
$updatedAt = $order->getCreatedAt()->format('Y-m-d H:i:s');
try {
if ($order->getTransactions() instanceof OrderTransactionCollection) {
$paymentProvider = $order->getTransactions()->first()->getPaymentMethod()->getName();
$paymentProvider = $order->getTransactions()?->first()?->getPaymentMethod()?->getTranslation('name');
} else {
throw new NostoException('Order has no payment associated');
}
Expand Down
10 changes: 8 additions & 2 deletions src/Model/Nosto/Entity/Product/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,18 @@ public function build(SalesChannelProductEntity $product, SalesChannelContext $c
) {
foreach ($product->getOptions() as $option) {
if ($option->getGroup() !== null) {
$nostoProduct->addCustomField($option->getGroup()->getName(), $option->getName());
$nostoProduct->addCustomField(
$option->getGroup()->getTranslation('name'),
$option->getTranslation('name'),
TobiasGraml11 marked this conversation as resolved.
Show resolved Hide resolved
);
}
}
foreach ($product->getProperties() as $property) {
if ($property->getGroup() !== null) {
$nostoProduct->addCustomField($property->getGroup()->getName(), $property->getName());
$nostoProduct->addCustomField(
$property->getGroup()->getTranslation('name'),
$property->getTranslation('name'),
);
}
}

Expand Down
7 changes: 6 additions & 1 deletion src/Model/Nosto/Entity/Product/CachedProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ public function __construct(

public function get(SalesChannelProductEntity $product, SalesChannelContext $context): NostoProduct
{
$cacheKey = self::CACHE_PREFIX . $product->getId();
$cacheKey = implode('_', [
self::CACHE_PREFIX,
$product->getId(),
$context->getSalesChannelId(),
$context->getLanguageId(),
]);
$cachedItem = $this->cache->getItem($cacheKey);

if ($cachedItem->isHit()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ public function build(string $productId, SalesChannelContext $context): array
$crossSellings = $this->loadCrossSellings($productId, $context);
$result = [];
foreach ($crossSellings as $crossSelling) {
$result[$this->createKeyFromName($crossSelling->getName())] = [
$result[$this->createKeyFromName($crossSelling->getTranslation('name'))] = [
'productIds' => $this->useProductStream($crossSelling)
? $this->loadByStream($crossSelling, $context, new Criteria())
: $this->loadByIds($crossSelling, $context, new Criteria()),
'position' => $crossSelling->getPosition(),
'sortBy' => $crossSelling->getSortBy(),
'sortDirection' => $crossSelling->getSortDirection(),
'limit' => $crossSelling->getLimit(),
'name' => $crossSelling->getName(),
'name' => $crossSelling->getTranslation('name'),
];
}
return $result;
Expand Down
5 changes: 4 additions & 1 deletion src/Model/Nosto/Entity/Product/SkuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ public function build(ProductEntity $product, SalesChannelContext $context): Nos
) {
foreach ($product->getOptions() as $propertyOption) {
if ($propertyOption->getGroup() !== null) {
$nostoSku->addCustomField($propertyOption->getGroup()->getName(), $propertyOption->getName());
$nostoSku->addCustomField(
$propertyOption->getGroup()->getTranslation('name'),
$propertyOption->getTranslation('name'),
);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Operation/ProductSyncHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,8 @@ private function doUpsertOperation(
}
}

$nostoProducts = [];

// TODO: up to 2MB payload !
if ($product->getChildCount() && $product->getVariantListingConfig()?->getDisplayParent() === null) {
$nostoProducts = $this->resolveVariantProducts($product, $context);
Expand Down