Skip to content

Commit

Permalink
Merge branch '4.0' into 4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dpfaffenbauer committed Nov 24, 2024
2 parents 75a04e5 + e94b102 commit e13d791
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 8 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG-3.2.x.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# 3.2.15
* [PayumBundle] remove payment_state processing to confirm orders by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2743

# 3.2.14
* [Pimcore] introduce LocalizedFallbackHelper by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2723
* [Translations] add missing translations by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2721
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG-4.0.x.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
# 4.0.12

* [PayumBundle] remove payment_state processing to confirm orders by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2743
* [Docs] Upgrade guide: Mention emergency recovery if major version got updated without updating to latest minor version first by @BlackbitDevs in https://github.com/coreshop/CoreShop/pull/2745
* [Core] allow multiple store-values by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2747
* [CoreBundle] fix quantity price rules customerGroups condition by @dpfaffenbauer in https://github.com/coreshop/CoreShop/pull/2750

## 4.0.11

* [Pimcore] use getCount() instead of getTotalCount() for BatchListing by @hethehe in https://github.com/coreshop/CoreShop/pull/2715
Expand Down
4 changes: 4 additions & 0 deletions docs/01_Getting_Started/02_Upgrade_Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ directly, you might miss migrations. Always update to the latest Minor release v

This also means that if you do major updates, you will have old migrations in your Database. You can manually remove those
if you want to keep your Migrations Table clean.

If you already updated the major version and recognize that some migrations from your previous version to latest minor release version are missing, you can compare the database structure via
`bin/console doctrine:schema:update --dump-sql`
Please manually review the SQL statements before executing
7 changes: 6 additions & 1 deletion src/CoreShop/Bundle/CoreBundle/CoreExtension/StoreValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ public function createDataCopy(Concrete $object, mixed $data): mixed
public function load(Localizedfield|\Pimcore\Model\DataObject\Fieldcollection\Data\AbstractData|AbstractData|Concrete $object, array $params = []): mixed
{
if (isset($params['force']) && $params['force']) {
return $this->getProductStoreValuesRepository()->findForProduct($object);
return $this->getProductStoreValuesRepository()->findForObject($object, $this->getName());
}

return null;
Expand Down Expand Up @@ -451,14 +451,17 @@ public function save(Localizedfield|\Pimcore\Model\DataObject\Fieldcollection\Da
if (count($changeSet) > 0) {
$productStoreValue = clone $productStoreValue;
$productStoreValue->setProduct($object);
$productStoreValue->setFieldName($this->getName());
}
} else {
$productStoreValue->setProduct($object);
$productStoreValue->setFieldName($this->getName());
}
}

if (null === $productStoreValue->getProduct()) {
$productStoreValue->setProduct($object);
$productStoreValue->setFieldName($this->getName());
}

$this->getEntityManager()->persist($productStoreValue);
Expand Down Expand Up @@ -669,6 +672,7 @@ public function getDataFromEditmode($data, $object = null, $params = []): mixed
if ($storeValuesEntity instanceof ProductStoreValuesInterface && $storeValuesEntity->getProduct() && $storeValuesEntity->getProduct()->getId() !== $object->getId()) {
$storeValuesEntity = clone $storeValuesEntity;
$storeValuesEntity->setProduct($object);
$storeValuesEntity->setFieldName($this->getName());
}

$form = $this->getFormFactory()->createNamed('', ProductStoreValuesType::class, $storeValuesEntity);
Expand Down Expand Up @@ -735,6 +739,7 @@ public function createNew($object, StoreInterface $store)
$newObject = $this->getFactory()->createNew();
$newObject->setStore($store);
$newObject->setProduct($object);
$newObject->setFieldName($this->getName());

return $newObject;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,26 +23,52 @@
use CoreShop\Component\Core\Model\ProductStoreValuesInterface;
use CoreShop\Component\Core\Repository\ProductStoreValuesRepositoryInterface;
use CoreShop\Component\Store\Model\StoreInterface;
use Pimcore\Model\DataObject\Concrete;

class ProductStoreValuesRepository extends EntityRepository implements ProductStoreValuesRepositoryInterface
{
public function findForProduct(ProductInterface $product): array
{
if (!$product instanceof Concrete) {
throw new \InvalidArgumentException('Product must be instance of ' . Concrete::class);
}

return $this->findForObject($product, 'storeValues');
}

public function findForProductAndStore(ProductInterface $product, StoreInterface $store): ?ProductStoreValuesInterface
{
if (!$product instanceof Concrete) {
throw new \InvalidArgumentException('Product must be instance of ' . Concrete::class);
}

return $this->findForObjectAndStore($product, 'storeValues', $store);
}

public function findForObject(Concrete $product, string $fieldName): array
{
return $this->createQueryBuilder('o')
->andWhere('o.product = :product')
->andWhere('o.fieldName = :fieldName')
->setParameter('product', $product->getId())
->setParameter('fieldName', $fieldName)
->getQuery()
->getResult()
;
}

public function findForProductAndStore(ProductInterface $product, StoreInterface $store): ?ProductStoreValuesInterface
{
public function findForObjectAndStore(
Concrete $product,
string $fieldName,
StoreInterface $store,
): ?ProductStoreValuesInterface {
return $this->createQueryBuilder('o')
->andWhere('o.product = :product')
->andWhere('o.fieldName = :fieldName')
->andWhere('o.store = :store')
->setParameter('product', $product->getId())
->setParameter('store', $store)
->setParameter('fieldName', $fieldName)
->getQuery()
->getOneOrNullResult()
;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<?php

declare(strict_types=1);

/*
* CoreShop
*
* This source file is available under two different licenses:
* - GNU General Public License version 3 (GPLv3)
* - CoreShop Commercial License (CCL)
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) CoreShop GmbH (https://www.coreshop.org)
* @license https://www.coreshop.org/license GPLv3 and CCL
*
*/

namespace CoreShop\Bundle\CoreBundle\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241105123053 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
if ($schema->getTable('coreshop_product_store_values')->hasColumn('fieldName')) {
return;
}

$this->addSql('ALTER TABLE coreshop_product_store_values ADD fieldName VARCHAR(255) NOT NULL;');
$this->addSql('DROP INDEX product_store ON coreshop_product_store_values;');
$this->addSql('CREATE UNIQUE INDEX product_store ON coreshop_product_store_values (product, store, fieldName);');
$this->addSql("UPDATE coreshop_product_store_values SET fieldName='storeValues';");
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
<mapped-superclass name="CoreShop\Component\Core\Model\ProductStoreValues"
table="coreshop_product_store_values">
<unique-constraints>
<unique-constraint name="product_store" columns="product,store"/>
<unique-constraint name="product_store" columns="product,store,fieldName"/>
</unique-constraints>

<id name="id" column="id" type="integer">
<generator strategy="AUTO"/>
</id>

<field name="fieldName" column="fieldName" type="string"/>
<field name="product" column="product" type="pimcoreObject"/>
<field name="price" column="price" type="bigintInteger"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
*/

pimcore.registerNS('coreshop.product_quantity_price_rules.conditions.guest');
coreshop.product_quantity_price_rules.conditions.customerGroups = Class.create(coreshop.product.pricerule.conditions.guest, {});
coreshop.product_quantity_price_rules.conditions.guest = Class.create(coreshop.product.pricerule.conditions.guest, {});
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function execute($request): void
$payment = $request->getFirstModel();
$order = $payment->getOrder();
if ($payment->getState() === PaymentInterface::STATE_COMPLETED ||
$payment->getState() === PaymentInterface::STATE_AUTHORIZED ||
$payment->getState() === PaymentInterface::STATE_PROCESSING
$payment->getState() === PaymentInterface::STATE_AUTHORIZED
) {
$this->stateMachineApplier->apply($order, OrderTransitions::IDENTIFIER, OrderTransitions::TRANSITION_CONFIRM);

Expand Down
11 changes: 11 additions & 0 deletions src/CoreShop/Component/Core/Model/ProductStoreValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class ProductStoreValues extends AbstractResource implements ProductStoreValuesI
use StoreAwareTrait;

protected ?int $id = null;
protected ?string $fieldName = null;
protected int $price = 0;
protected ?TaxRuleGroupInterface $taxRule = null;
protected ?ProductInterface $product = null;
Expand All @@ -56,6 +57,16 @@ public function setId(int $id): void
$this->id = $id;
}

public function getFieldName(): ?string
{
return $this->fieldName;
}

public function setFieldName(?string $fieldName): void
{
$this->fieldName = $fieldName;
}

public function getPrice(): int
{
return $this->price;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ interface ProductStoreValuesInterface extends ResourceInterface, StoreAwareInter
{
public function getPrice(): int;

public function getFieldName(): ?string;

public function setFieldName(string $fieldName): void;

public function setPrice(int $price);

public function getProduct(): ?ProductInterface;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use CoreShop\Component\Core\Model\ProductStoreValuesInterface;
use CoreShop\Component\Resource\Repository\RepositoryInterface;
use CoreShop\Component\Store\Model\StoreInterface;
use Pimcore\Model\DataObject\Concrete;

interface ProductStoreValuesRepositoryInterface extends RepositoryInterface
{
Expand All @@ -31,4 +32,11 @@ interface ProductStoreValuesRepositoryInterface extends RepositoryInterface
public function findForProduct(ProductInterface $product): array;

public function findForProductAndStore(ProductInterface $product, StoreInterface $store): ?ProductStoreValuesInterface;

/**
* @return ProductStoreValuesInterface[]
*/
public function findForObject(Concrete $product, string $fieldName): array;

public function findForObjectAndStore(Concrete $product, string $fieldName, StoreInterface $store): ?ProductStoreValuesInterface;
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function getTranslation(string $locale = null, bool $useFallbackTranslati
return $translation;
}

if ($useFallbackTranslation) {
if ($useFallbackTranslation && null !== $this->fallbackLocale) {
$fallbackTranslation = $this->translations->get($this->fallbackLocale);
if (null !== $fallbackTranslation) {
$this->translationsCache[$this->fallbackLocale] = $fallbackTranslation;
Expand Down

0 comments on commit e13d791

Please sign in to comment.