Skip to content

Commit

Permalink
Merge branch '4.1' into next
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Feb 17, 2025
2 parents 00cceb0 + ad200f7 commit 6003975
Show file tree
Hide file tree
Showing 20 changed files with 315 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/behat_ui.yml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ jobs:
run: vendor/bin/behat --strict --no-interaction -vvv -f progress --config behat.yml.dist -p ui

- name: Upload Logs
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
if: failure()
with:
name: "Logs (PHP ${{ matrix.php }}, Symfony ${{ matrix.pimcore }})"
Expand Down
23 changes: 23 additions & 0 deletions features/domain/filter/load_index_with_raw_results.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@domain @filter
Feature: To get more performance out of the index, we can also load the raw result
without needing pimcore's data objects

Background:
Given the site operates on a store in "Austria"
And the site has a index "myindex" for class "CoreShopProduct" with type "mysql"
And the site has a filter "myfilter" for index "myindex"
And the index has following fields:
| key | name | type | getter | interpreter | columnType |
| sku | sku | object | | | STRING |
| ean | ean | object | | | STRING |
| name | internalName | localizedfields | localizedfield | localeMapping | STRING |

Scenario: Adding a simple product to the index
And the site has a product "Shoe" priced at 100
And the products ean is "123456"
And the products sku is "654321"
And the product is active
And the product is published
Then the raw result for the filter should look like:
| o_classId | o_className | o_type | active | categoryIds | parentCategoryIds | sku | ean | language | name | internalName |
| cs_product | CoreShopProduct | object | 1 | ,, | ,, | 654321 | 123456 | en | Shoe | Shoe |
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
@domain @payment_provider
Feature: Adding a new Payment Provider Rule
In order to payment costs
I'll create a new payment-provider-rule
with an carrier condition

Background:
Given the site operates on a store in "Austria"
And the site has a currency "Euro" with iso "EUR"
And I am in country "Austria"
And the site has a product "Shoe" priced at 10000
And I add the product "Shoe" to my cart
And There is a payment provider "Bankwire" using factory "Bankwire"
And the site has a carrier "Post"
And the carrier "Post" is enabled for store "Austria"
And my cart uses carrier "Post"

Scenario: Add a new carrier payment-provider-rule which is valid
Given adding a payment-provider-rule named "carriers"
And the payment-provider-rule is active
And the payment-provider-rule has a condition carriers with carrier "Post"
Then the payment-provider-rule should be valid for my cart with payment provider "Bankwire"

Scenario: Add a new carrier payment-provider-rule which is inactive
Given adding a payment-provider-rule named "carriers"
And the payment-provider-rule is inactive
And the payment-provider-rule has a condition currencies with currency "EUR"
Then the payment-provider-rule should be invalid for my cart with payment provider "Bankwire"

Scenario: Add a new carrier payment-provider-rule which is invalid
Given the site has a carrier "DHL"
And adding a payment-provider-rule named "carriers"
And the payment-provider-rule is active
And the payment-provider-rule has a condition carriers with carrier "DHL"
Then the payment-provider-rule should be invalid for my cart with payment provider "Bankwire"
40 changes: 40 additions & 0 deletions src/CoreShop/Behat/Context/Domain/FilterContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use CoreShop\Component\Index\Filter\FilterProcessorInterface;
use CoreShop\Component\Index\Listing\ListingInterface;
use CoreShop\Component\Index\Listing\OrderAwareListingInterface;
use CoreShop\Component\Index\Listing\RawResultListingInterface;
use CoreShop\Component\Index\Model\FilterConditionInterface;
use CoreShop\Component\Index\Model\FilterInterface;
use CoreShop\Component\Index\Model\IndexableInterface;
Expand Down Expand Up @@ -229,6 +230,45 @@ public function ifIQueryWithASimpleOrder(FilterInterface $filter, $orderKey, $or
Assert::eq([$firstResult, $secondResult], $result);
}

/**
* @Then /^the raw result for the (filter) should look like:$/
*/
public function theRawResultForTheFilterShouldLookLike(FilterInterface $filter, TableNode $table): void
{
$parameterBag = new ParameterBag();

$filteredList = $this->filterListFactory->createList($filter, $parameterBag);
$filteredList->setLocale('en');
$filteredList->setVariantMode(ListingInterface::VARIANT_MODE_HIDE);

if (!$filteredList instanceof RawResultListingInterface) {
throw new \RuntimeException('FilteredList is not an instance of RawResultListingInterface');
}

$tableRaw = array_values($table->getTable());
$header = null;
$data = [];

foreach ($tableRaw as $index => $value) {
if ($index === 0) {
$header = $value;

continue;
}

$data[] = array_combine($header, $value);
}

$rawResult = $filteredList->loadRawResult();

foreach ($data as $rowIndex => $entry) {
foreach ($entry as $key => $value) {
Assert::keyExists($rawResult[$rowIndex], $key);
Assert::eq($rawResult[$rowIndex][$key], $value);
}
}
}

private function prepareFilter(FilterInterface $filter, array $filterParams = []): array
{
$parameterBag = new ParameterBag($filterParams);
Expand Down
11 changes: 11 additions & 0 deletions src/CoreShop/Behat/Context/Setup/CartContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use CoreShop\Bundle\OrderBundle\Form\Type\AddToCartType;
use CoreShop\Bundle\TestBundle\Service\SharedStorageInterface;
use CoreShop\Component\Address\Model\AddressInterface;
use CoreShop\Component\Core\Model\CarrierInterface;
use CoreShop\Component\Core\Model\CustomerInterface;
use CoreShop\Component\Core\Model\OrderInterface;
use CoreShop\Component\Core\Model\OrderItemInterface;
Expand Down Expand Up @@ -218,6 +219,16 @@ public function myCartIsUsingCurrency(OrderInterface $cart, CurrencyInterface $c
$this->cartManager->persistCart($cart);
}

/**
* @Given /^(my cart) uses (carrier "[^"]+")$/
*/
public function myCartIsUsingCarrier(OrderInterface $cart, CarrierInterface $carrier): void
{
$cart->setCarrier($carrier);

$this->cartManager->persistCart($cart);
}

/**
* @Given /^(my cart) uses (store "[^"]+")$/
*/
Expand Down
15 changes: 15 additions & 0 deletions src/CoreShop/Behat/Context/Setup/PaymentContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
use CoreShop\Bundle\CoreBundle\Form\Type\Payment\Rule\Action\AdditionAmountActionConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Payment\Rule\Action\DiscountAmountActionConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Payment\Rule\Action\PriceActionConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CarriersConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CategoriesConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CountriesConfigurationType;
use CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CurrenciesConfigurationType;
Expand All @@ -41,6 +42,7 @@
use CoreShop\Bundle\RuleBundle\Form\Type\Rule\EmptyConfigurationFormType;
use CoreShop\Bundle\TestBundle\Service\SharedStorageInterface;
use CoreShop\Component\Address\Model\ZoneInterface;
use CoreShop\Component\Core\Model\CarrierInterface;
use CoreShop\Component\Core\Model\CategoryInterface;
use CoreShop\Component\Core\Model\CountryInterface;
use CoreShop\Component\Core\Model\CurrencyInterface;
Expand Down Expand Up @@ -522,6 +524,19 @@ public function thePaymentProviderRuleHasAPriceAction(PaymentProviderRuleInterfa
]));
}

/**
* @Given /^the (payment-provider-rule "[^"]+") has a condition carriers with (carrier "[^"]+")$/
* @Given /^the (payment-provider-rule) has a condition carriers with (carrier "[^"]+")$/
*/
public function thePaymentProviderRuleHasACarriersCondition(PaymentProviderRuleInterface $rule, CarrierInterface $carrier): void
{
$this->assertConditionForm(CarriersConfigurationType::class, 'carriers');

$this->addCondition($rule, $this->createConditionWithForm('carriers', [
'carriers' => [$carrier->getId()],
]));
}

/**
* @Given /^the (payment-provider-rule "[^"]+") has a action additional-amount of ([^"]+) in (currency "[^"]+")$/
* @Given /^the (payment-provider-rule) has a action additional-amount of ([^"]+) in (currency "[^"]+")$/
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,35 @@
---
coreshop_country: 'Kraj'
coreshop_country_isoCode: 'Kod ISO'
coreshop_country_currency: 'Waluta'
coreshop_zone: 'Strefa'
coreshop_country_multiselect: 'Wielokrotny wybór krajów'
coreshop_state: 'Stan'
coreshop_state_isoCode: 'Kod ISO'
coreshop_state_country: 'Kraj'
coreshop_country_addressFormat: 'Format adresu'
coreshop_country_salutations: 'Zwroty grzecznościowe'
coreshop_permission_country: 'CoreShop: Kraj'
coreshop_permission_state: 'CoreShop: Stan'
coreshop_permission_zone: 'CoreShop: Strefa'
coreshop_address_company: 'Firma'
coreshop_address_firstname: 'Imię'
coreshop_address_lastname: 'Nazwisko'
coreshop_address_postcode: 'Kod pocztowy'
coreshop_address_city: 'Miasto'
coreshop_address_street: 'Ulica'
coreshop_address_street_number: 'Numer ulicy'
coreshop_address_identifier: 'Identyfikator adresu'
coreshop_countries: 'Kraje'
CoreShopAddress: 'Adres'
coreshop.address.salutation: 'Zwrot grzecznościowy'
coreshop.address.firstname: 'Imię'
coreshop.address.lastname: 'Nazwisko'
coreshop.address.company: 'Firma'
coreshop.address.street: 'Ulica'
coreshop.address.number: 'Numer'
coreshop.address.post_code: 'Kod pocztowy'
coreshop.address.city: 'Miasto'
coreshop.address.country: 'Kraj'
coreshop.address.state: 'Stan/Województwo'
coreshop.address.phone_number: 'Numer telefonu'
coreshop.address.address_identifier: 'Identyfikator adresu'
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
use CoreShop\Component\Order\OrderSaleStates;
use CoreShop\Component\Order\Repository\OrderItemRepositoryInterface;
use CoreShop\Component\Pimcore\DataObject\VersionHelper;
use Doctrine\DBAL\Connection;
use Pimcore\Event\Model\DataObjectEvent;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\FactoryInterface;

final class ProductAvailabilityEventListener
{
private array $productIdsToCheck = [];

public function __construct(
private OrderItemRepositoryInterface $cartItemRepository,
private FactoryInterface $pimcoreModelFactory,
private Connection $db,
) {
}

Expand All @@ -50,27 +50,16 @@ public function preUpdateListener(DataObjectEvent $event): void
return;
}

if (in_array($object->getId(), $this->productIdsToCheck, true)) {
return;
}

/** @psalm-suppress InternalMethod */
$originalItem = $this->pimcoreModelFactory->build($object::class);
$originalItem->getDao()->getById($object->getId());

if (!$originalItem instanceof PurchasableInterface) {
return;
}

if (!$object instanceof Concrete) {
return;
}

if (!$originalItem instanceof Concrete) {
if (in_array($object->getId(), $this->productIdsToCheck, true)) {
return;
}

if ($object->getPublished() === $originalItem->isPublished()) {
$originalPublished = (bool)$this->db->fetchOne('SELECT published FROM objects WHERE id=?', [$object->getId()]);
if ($object->getPublished() === $originalPublished) {
return;
}

Expand Down
27 changes: 13 additions & 14 deletions src/CoreShop/Bundle/CoreBundle/Resources/config/pimcore/admin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,20 +38,6 @@ core_shop_core:
shipping_rule_actions_addition_amount: '/bundles/coreshopcore/pimcore/js/shipping/rules/actions/additionAmount.js'
shipping_rule_actions_discount_amount: '/bundles/coreshopcore/pimcore/js/shipping/rules/actions/discountAmount.js'
shipping_rule_actions_price: '/bundles/coreshopcore/pimcore/js/shipping/rules/actions/price.js'

payment_provider_rule_conditions_categories: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/categories.js'
payment_provider_rule_conditions_countries: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/countries.js'
payment_provider_rule_conditions_currencies: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/currencies.js'
payment_provider_rule_conditions_customerGroups: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/customerGroups.js'
payment_provider_rule_conditions_customers: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/customers.js'
payment_provider_rule_conditions_guest: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/guest.js'
payment_provider_rule_conditions_products: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/products.js'
payment_provider_rule_conditions_stores: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/stores.js'
payment_provider_rule_conditions_zones: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/zones.js'
payment_provider_rule_actions_addition_amount: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/additionAmount.js'
payment_provider_rule_actions_discount_amount: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/discountAmount.js'
payment_provider_rule_actions_price: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/price.js'

product_price_rule_condition_countries: '/bundles/coreshopcore/pimcore/js/product/pricerule/conditions/countries.js'
product_price_rule_condition_currencies: '/bundles/coreshopcore/pimcore/js/product/pricerule/conditions/currencies.js'
product_price_rule_condition_customer_groups: '/bundles/coreshopcore/pimcore/js/product/pricerule/conditions/customerGroups.js'
Expand Down Expand Up @@ -130,6 +116,19 @@ core_shop_core:
notification_rule_condition_invoice_transition: '/bundles/coreshopcore/pimcore/js/notification/conditions/invoice/invoiceTransition.js'
notification_rule_condition_user_user_type: '/bundles/coreshopcore/pimcore/js/notification/conditions/user/userType.js'
notification_rule_condition_all_stores: '/bundles/coreshopcore/pimcore/js/notification/conditions/all/stores.js'
payment_provider_rule_conditions_categories: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/categories.js'
payment_provider_rule_conditions_carriers: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/carriers.js'
payment_provider_rule_conditions_countries: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/countries.js'
payment_provider_rule_conditions_currencies: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/currencies.js'
payment_provider_rule_conditions_customerGroups: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/customerGroups.js'
payment_provider_rule_conditions_customers: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/customers.js'
payment_provider_rule_conditions_guest: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/guest.js'
payment_provider_rule_conditions_products: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/products.js'
payment_provider_rule_conditions_stores: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/stores.js'
payment_provider_rule_conditions_zones: '/bundles/coreshopcore/pimcore/js/payment/rules/conditions/zones.js'
payment_provider_rule_actions_addition_amount: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/additionAmount.js'
payment_provider_rule_actions_discount_amount: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/discountAmount.js'
payment_provider_rule_actions_price: '/bundles/coreshopcore/pimcore/js/payment/rules/actions/price.js'
object_grid_column_store_price: '/bundles/coreshopcore/pimcore/js/object/gridcolumn/operator/storePrice.js'
product_store_preview: '/bundles/coreshopcore/pimcore/js/product/preview.js'
workflow_variant_unit_definition_solidifier: '/bundles/coreshopcore/pimcore/js/workflow/variantUnitDefinitionSolidifier.js'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ services:
CoreShop\Bundle\CoreBundle\EventListener\ProductAvailabilityEventListener:
arguments:
- '@coreshop.repository.order_item'
- '@Pimcore\Model\Factory'
- '@doctrine.dbal.default_connection'
tags:
- { name: kernel.event_listener, event: pimcore.dataobject.preUpdate, method: preUpdateListener }
- { name: kernel.event_listener, event: pimcore.dataobject.postUpdate, method: postUpdateListener }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ services:
tags:
- { name: coreshop.payment_provider_rule.condition, type: currencies, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CurrenciesConfigurationType }

CoreShop\Component\Core\Payment\Rule\Condition\CarrierConditionChecker:
tags:
- { name: coreshop.payment_provider_rule.condition, type: carriers, form-type: CoreShop\Bundle\CoreBundle\Form\Type\Rule\Condition\CarriersConfigurationType }



# Actions
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* CoreShop.
*
* This source file is subject to the GNU General Public License version 3 (GPLv3)
* For the full copyright and license information, please view the LICENSE.md and gpl-3.0.txt
* files that are distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GPLv3 and CCL
*
*/

pimcore.registerNS('coreshop.paymentproviderrule.conditions.carriers');
coreshop.paymentproviderrule.conditions.carriers = Class.create(coreshop.cart.pricerules.conditions.carriers, {});
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

use CoreShop\Component\Core\Context\ShopperContextInterface;
use CoreShop\Component\Core\Currency\CurrencyStorageInterface;
use CoreShop\Component\Core\Model\CurrencyInterface;
use CoreShop\Component\Core\Repository\CurrencyRepositoryInterface;
use CoreShop\Component\Order\Context\CartContextInterface;
use CoreShop\Component\Order\Manager\CartManagerInterface;
Expand All @@ -46,6 +47,11 @@ public function switchAction(Request $request): Response

$currencyCode = $this->getParameterFromRequest($request, 'currencyCode');
$currency = $this->getCurrencyRepository()->getByCode($currencyCode);

if (!$currency instanceof CurrencyInterface) {
throw $this->createNotFoundException();
}

$cartManager = $this->container->get(CartManagerInterface::class);
$cartContext = $this->container->get(CartContextInterface::class);
$cart = $cartContext->getCart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@
</div>

<div class="row">
{% set type = type == 'grid' or type == 'list' ? type : 'list' %}

{% for product in paginator.items %}
{% include '@CoreShopFrontend/Category/_'~type~'.html.twig' with {
product: product,
Expand Down
Loading

0 comments on commit 6003975

Please sign in to comment.