Skip to content

Commit

Permalink
added Vat to frontend API for product, transport and payment
Browse files Browse the repository at this point in the history
- also updated Convertim implementation
  • Loading branch information
TomasLudvik committed Oct 31, 2024
1 parent 53b083f commit c787d2a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/Model/Product/Elasticsearch/ProductExportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ protected function getExportedFieldValue(int $domainId, Product $product, string
ProductExportFieldProvider::SEO_META_DESCRIPTION => $product->getSeoMetaDescription($domainId),
ProductExportFieldProvider::ACCESSORIES => $this->extractAccessoriesIds($product),
ProductExportFieldProvider::HREFLANG_LINKS => $this->hreflangLinksFacade->getForProduct($product, $domainId),
ProductExportFieldProvider::VAT => $this->extractVat($product, $domainId),
default => throw new InvalidArgumentException(sprintf('There is no definition for exporting "%s" field to Elasticsearch', $field)),
};
}
Expand Down Expand Up @@ -444,4 +445,16 @@ protected function reset(): void
{
$this->inMemoryCache->deleteAllItemsInNamespace(static::VARIANTS_CACHE_NAMESPACE);
}

/**
* @param \Shopsys\FrameworkBundle\Model\Product\Product $product
* @param int $domainId
* @return array
*/
protected function extractVat(Product $product, int $domainId): array
{
return [
'percent' => $product->getVatForDomain($domainId)->getPercent(),
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class ProductExportFieldProvider
public const string SEO_META_DESCRIPTION = 'seo_meta_description';
public const string ACCESSORIES = 'accessories';
public const string HREFLANG_LINKS = 'hreflang_links';
public const string VAT = 'vat';

/**
* @return string[]
Expand Down
2 changes: 2 additions & 0 deletions src/Model/Product/Search/ProductElasticsearchConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function fillEmptyFields(array $product): array
$result['seo_meta_description'] = $product['seo_meta_description'] ?? null;
$result['hreflang_links'] = $product['hreflang_links'] ?? [];

$result['vat'] = $product['vat'] ?? ['percent' => '0'];

return $result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function testFillEmptyFields(): void
'seo_title' => null,
'seo_meta_description' => null,
'hreflang_links' => [],
'vat' => [],
];

$converter = new ProductElasticsearchConverter();
Expand Down Expand Up @@ -118,6 +119,7 @@ public function testFillEmptyParameterFields(): void
'seo_title' => null,
'seo_meta_description' => null,
'hreflang_links' => [],
'vat' => [],
];

$converter = new ProductElasticsearchConverter();
Expand Down

0 comments on commit c787d2a

Please sign in to comment.