Skip to content

Commit

Permalink
update master branch by changes in 9.0.x-dev (branch 9.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
David Stritezsky committed Jul 16, 2020
2 parents ecdfa28 + 70b5330 commit 39265e7
Show file tree
Hide file tree
Showing 17 changed files with 209 additions and 43 deletions.
4 changes: 1 addition & 3 deletions assets/js/frontend/utils/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ const defaults = {
buttonClose: true,
buttonCancel: false,
buttonContinue: false,
textContinue: Translator.trans('Yes'),
textCancel: Translator.trans('No'),
textHeading: '',
urlContinue: '#',
cssClass: 'window-popup--standard',
Expand Down Expand Up @@ -40,7 +38,7 @@ export default class Window {
constructor (inputOptions) {
this.$activeWindow = null;

this.options = $.extend(defaults, inputOptions);
this.options = { textContinue: Translator.trans('Yes'), textCancel: Translator.trans('No'), ...defaults, ...inputOptions };

if (this.$activeWindow !== null) {
this.$activeWindow.trigger('windowFastClose');
Expand Down
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<property name="path.root" value="${project.basedir}"/>
<property name="path.vendor" value="${path.root}/vendor"/>
<property name="path.framework" value="${path.vendor}/shopsys/framework"/>
<property name="path.framework.assets" value="node_modules/@shopsys/framework"/>
<property name="path.framework.assets" value="${path.root}/node_modules/@shopsys/framework"/>
<property name="path.frontend-api" value="${path.vendor}/shopsys/frontend-api"/>

<property name="phpstan.level" value="4"/>
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"shopsys/product-feed-zbozi": "9.1.x-dev",
"shopsys/product-feed-google": "9.1.x-dev",
"shopsys/read-model": "9.1.x-dev",
"snc/redis-bundle": "^3.2.1",
"snc/redis-bundle": "^3.2.2",
"stof/doctrine-extensions-bundle": "^1.3.0",
"symfony-cmf/routing": "^2.0.3",
"symfony-cmf/routing-bundle": "^2.0.3",
Expand Down
1 change: 1 addition & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ security:
- { path: ^/login-as-remembered-user/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/superadmin/, roles: ROLE_SUPER_ADMIN }
- { path: ^/admin/cron/*, roles: ROLE_SUPER_ADMIN }
- { path: ^/admin/currency/, roles: ROLE_SUPER_ADMIN }
- { path: ^/admin/translation/list/$, roles: ROLE_SUPER_ADMIN }
- { path: ^/admin/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
- { path: ^/admin/authorization/$, roles: IS_AUTHENTICATED_ANONYMOUSLY }
Expand Down
1 change: 1 addition & 0 deletions config/packages/snc_redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,5 @@ snc_redis:
dsn: 'redis://%redis_host%'
session:
client: 'session'
ttl: 604800
prefix: '%env(REDIS_PREFIX)%session:'
1 change: 1 addition & 0 deletions docker/conf/docker-compose.prod.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ services:
extra_hosts:
- postgres:192.168.0.1
- redis:192.168.0.1
- elasticsearch:192.168.0.1
networks:
- shopsys-network

Expand Down
1 change: 0 additions & 1 deletion docker/php-fpm/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ RUN apt-get update && \
autoconf && \
apt-get clean

# "gd" extension needs to have specified jpeg and freetype dir for jpg/jpeg images support
RUN docker-php-ext-configure gd --with-freetype --with-jpeg

# install necessary tools for running application
Expand Down
2 changes: 1 addition & 1 deletion docker/php-fpm/docker-php-entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ PIPE=/tmp/log-pipe
rm -rf $PIPE
mkfifo $PIPE
chmod 666 $PIPE
tail -f $PIPE &
tail -n +1 -f $PIPE &

# first arg is `-f` or `--some-option`
if [ "${1#-}" != "$1" ]; then
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Front/OrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function indexAction()
if ($isValid) {
if ($orderFlow->nextStep()) {
$form = $orderFlow->createForm();
} elseif ($this->isFlashMessageBagEmpty()) {
} elseif (count($this->getErrorMessages()) === 0 && count($this->getInfoMessages()) === 0) {
$deliveryAddress = $orderData->deliveryAddressSameAsBillingAddress === false ? $frontOrderFormData->deliveryAddress : null;
$order = $this->orderFacade->createOrderFromFront($orderData, $deliveryAddress);
$this->orderFacade->sendHeurekaOrderInfo($order, $frontOrderFormData->disallowHeurekaVerifiedByCustomers);
Expand Down
76 changes: 57 additions & 19 deletions src/DataFixtures/Demo/ProductDataFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use DateTime;
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManagerInterface;
use Shopsys\FrameworkBundle\Component\DataFixture\AbstractReferenceFixture;
use Shopsys\FrameworkBundle\Component\Domain\Domain;
use Shopsys\FrameworkBundle\Component\Money\Money;
Expand Down Expand Up @@ -72,26 +73,26 @@ class ProductDataFixture extends AbstractReferenceFixture implements DependentFi
*/
private $parameterDataFactory;

/**
* @var \Shopsys\FrameworkBundle\Model\Product\Parameter\Parameter[]
*/
private $parameters;

/**
* @var int
*/
private $productNo = 1;

/**
* @var \App\Model\Product\Product[]
* @var int[]
*/
private $productsByCatnum = [];
private $productIdsByCatnum = [];

/**
* @var \Shopsys\FrameworkBundle\Model\Pricing\PriceConverter
*/
private $priceConverter;

/**
* @var \Doctrine\ORM\EntityManagerInterface
*/
private $em;

/**
* @param \Shopsys\FrameworkBundle\Model\Product\ProductFacade $productFacade
* @param \Shopsys\FrameworkBundle\Model\Product\ProductVariantFacade $productVariantFacade
Expand All @@ -103,6 +104,7 @@ class ProductDataFixture extends AbstractReferenceFixture implements DependentFi
* @param \Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterFacade $parameterFacade
* @param \Shopsys\FrameworkBundle\Model\Product\Parameter\ParameterDataFactory $parameterDataFactory
* @param \Shopsys\FrameworkBundle\Model\Pricing\PriceConverter $priceConverter
* @param \Doctrine\ORM\EntityManagerInterface $em
*/
public function __construct(
ProductFacade $productFacade,
Expand All @@ -114,7 +116,8 @@ public function __construct(
ParameterValueDataFactory $parameterValueDataFactory,
ParameterFacade $parameterFacade,
ParameterDataFactory $parameterDataFactory,
PriceConverter $priceConverter
PriceConverter $priceConverter,
EntityManagerInterface $em
) {
$this->productFacade = $productFacade;
$this->productVariantFacade = $productVariantFacade;
Expand All @@ -126,6 +129,7 @@ public function __construct(
$this->parameterFacade = $parameterFacade;
$this->parameterDataFactory = $parameterDataFactory;
$this->priceConverter = $priceConverter;
$this->em = $em;
}

/**
Expand Down Expand Up @@ -5636,11 +5640,11 @@ private function createVariants(): void

foreach ($variantCatnumsByMainVariantCatnum as $mainVariantCatnum => $variantsCatnums) {
/** @var \App\Model\Product\Product $mainProduct */
$mainProduct = $this->productsByCatnum[$mainVariantCatnum];
$mainProduct = $this->getProductFromCacheByCatnum($mainVariantCatnum);

$variants = [];
foreach ($variantsCatnums as $variantCatnum) {
$variants[] = $this->productsByCatnum[$variantCatnum];
$variants[] = $this->getProductFromCacheByCatnum($variantCatnum);
}

$mainVariant = $this->productVariantFacade->createVariant($mainProduct, $variants);
Expand All @@ -5654,12 +5658,6 @@ private function createVariants(): void
*/
private function findParameterByNamesOrCreateNew(array $parameterNamesByLocale): Parameter
{
$cacheId = json_encode($parameterNamesByLocale);

if (isset($this->parameters[$cacheId])) {
return $this->parameters[$cacheId];
}

$parameter = $this->parameterFacade->findParameterByNames($parameterNamesByLocale);

if ($parameter === null) {
Expand All @@ -5669,8 +5667,6 @@ private function findParameterByNamesOrCreateNew(array $parameterNamesByLocale):
$parameter = $this->parameterFacade->create($parameterData);
}

$this->parameters[$cacheId] = $parameter;

return $parameter;
}

Expand Down Expand Up @@ -5817,8 +5813,33 @@ private function setVat(ProductData $productData, ?string $vatReference): void
public function addProductReference(Product $product)
{
$this->addReference(self::PRODUCT_PREFIX . $this->productNo, $product);
$this->productsByCatnum[$product->getCatnum()] = $product;
$this->productNo++;

if (in_array($product->getCatnum(), $this->getAllVariantCatnumsFromAssociativeArray(self::getVariantCatnumsByMainVariantCatnum()), true)) {
$this->saveProductToCache($product);
}

$this->em->clear();
}

/**
* @param \App\Model\Product\Product $product
*/
private function saveProductToCache(Product $product): void
{
$this->productIdsByCatnum[$product->getCatnum()] = $product->getId();
}

/**
* @param string $catnum
* @return \App\Model\Product\Product
*/
private function getProductFromCacheByCatnum(string $catnum): Product
{
/** @var \App\Model\Product\Product $product */
$product = $this->productFacade->getById($this->productIdsByCatnum[$catnum]);

return $product;
}

/**
Expand All @@ -5836,4 +5857,21 @@ public function getDependencies(): array
SettingValueDataFixture::class,
];
}

/**
* @param array $productCatnumsByMainVariantCatnum
*
* @return string[]
*/
private function getAllVariantCatnumsFromAssociativeArray(array $productCatnumsByMainVariantCatnum): array
{
$catnums = [];

foreach ($productCatnumsByMainVariantCatnum as $mainVariantCatnum => $variantCatnums) {
$catnums[] = $mainVariantCatnum;
$catnums = array_merge($catnums, $variantCatnums);
}

return array_unique($catnums);
}
}
18 changes: 18 additions & 0 deletions symfony.lock
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@
"psr/container": {
"version": "1.0.0"
},
"psr/event-dispatcher": {
"version": "1.0.0"
},
"psr/http-message": {
"version": "1.0.1"
},
Expand Down Expand Up @@ -903,6 +906,9 @@
"symfony/polyfill-intl-idn": {
"version": "v1.12.0"
},
"symfony/polyfill-intl-normalizer": {
"version": "v1.18.0"
},
"symfony/polyfill-mbstring": {
"version": "v1.12.0"
},
Expand All @@ -918,6 +924,9 @@
"symfony/polyfill-php73": {
"version": "v1.12.0"
},
"symfony/polyfill-php80": {
"version": "v1.18.0"
},
"symfony/polyfill-util": {
"version": "v1.12.0"
},
Expand Down Expand Up @@ -1089,12 +1098,21 @@
"symplify/coding-standard": {
"version": "v5.4.16"
},
"symplify/console-color-diff": {
"version": "v7.3.18"
},
"symplify/easy-coding-standard": {
"version": "v5.4.13"
},
"symplify/package-builder": {
"version": "v5.4.16"
},
"symplify/parameter-name-guard": {
"version": "v7.3.18"
},
"symplify/phpstan-extensions": {
"version": "v7.3.18"
},
"symplify/set-config-resolver": {
"version": "v7.2.3"
},
Expand Down
2 changes: 1 addition & 1 deletion templates/Front/Content/Login/windowForm.html.twig
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
{{ init_js_validation(null, false) }}
{{ form_start(form, {attr: {class: 'js-front-login-window'}}) }}
{{ form_errors(form) }}

Expand Down Expand Up @@ -34,3 +33,4 @@
</div>

{{ form_end(form) }}
{{ init_js_validation(form, false) }}
6 changes: 6 additions & 0 deletions templates/Front/Content/Product/detail.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
<tr class="table-variants__row">
<th class="table-variants__cell table-variants__cell--image"></th>
<th class="table-variants__cell table-variants__cell--name">{{ 'Name'|trans }}</th>
<th class="table-variants__cell">{{ 'Availability'|trans }}</th>
<th class="table-variants__cell table-variants__cell--price">
{{ 'Price including VAT'|trans }}
{% if getProductSellingPrice(product) is not null %}
Expand Down Expand Up @@ -194,6 +195,11 @@
{{ variant.name }}
{% endif %}
</td>
<td class="table-variants__cell">
{% if variant.calculatedAvailability %}
{{ variant.calculatedAvailability.name }}
{% endif %}
</td>
<td class="table-variants__cell table-variants__cell--price">
{{ getProductSellingPrice(variant).priceWithVat|price }}
</td>
Expand Down
Loading

0 comments on commit 39265e7

Please sign in to comment.