Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevivally committed Jul 4, 2024
0 parents commit 9bd55fc
Show file tree
Hide file tree
Showing 112 changed files with 5,310 additions and 0 deletions.
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.idea/
.vscode/
/vendor/

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
Icon?
ehthumbs.db
Thumbs.db
2 changes: 2 additions & 0 deletions CHANGELOG_de-DE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# 3.0.11
* Warenkorb-Tracker verbessern: Der Warenkorb wird jetzt auf jeder Seite verfolgt und der Offcanvas-Warenkorb ist geöffnet
52 changes: 52 additions & 0 deletions CHANGELOG_en-GB.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# 3.0.11
* Improve cart tracker: Cart is now tracked on every page and offcanvas-cart open

# 3.0.10

* Fixed issue where feeds were generated even if the sales channel is marked as inactive

# 3.0.9

* Changed: "Save" button to not force generate feeds when Hello Retail sales channel is saved
* Added: Button to force generate feeds Hello Retail sales channel(s) (Administration)
* Category feed now only takes categories associated with the selected sales channel (Navigation, Footer & service menu)

# 3.0.8

* Fixed a bug in administration with saveFinish

# 3.0.7

* Fixed issue where administration broke when creating a new sales channel (Hello Retail)
* Added info message on "saveFinish"

# 3.0.6

* Made the option to include products in category feed default to OFF / false

# 3.0.5

* Fixed category body template error

# 3.0.4

* Made the option to include products in category feed default to ON / true for backwards compatibility
* Remove test code hardcoding the include products in category feed to false

# 3.0.3

* Fixed category export feed to not load product_stream products unless it's necessary
* Added option to include products in category feed (Default, false)

# 3.0.2

* Correction to "GET" request in administration

# 3.0.1

* Removed "product" association to avoid missing association warning in error log

# 3.0.0

* Added controller to ensure files can load cross sales channels using subfolder domain
* Changed administration to save default/new feed values as empty to allow overrides on default template
46 changes: 46 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"name": "helret/hello-retail",
"description": "Hello Retail integration for Shopware 6",
"type": "shopware-platform-plugin",
"license": "proprietary",
"version": "3.0.11",
"authors": [
{
"name": "WEXO A/S",
"homepage": "https://www.wexo.dk/"
}
],
"autoload": {
"psr-4": {
"Helret\\HelloRetail\\": "src/"
}
},
"require": {
"shopware/core": "^6.4"
},
"extra": {
"shopware-plugin-class": "Helret\\HelloRetail\\HelretHelloRetail",
"plugin-icon": "src/Resources/config/plugin.png",
"copyright": "(c) Hello Retail ApS",
"label": {
"da-DK": "Hello Retail",
"en-GB": "Hello Retail",
"de-DE": "Hello Retail"
},
"description": {
"da-DK": "Hello Retail integration",
"en-GB": "Hello Retail integration",
"de-DE": "Hello Retail integration"
},
"manufacturerLink": {
"dk-DK": "https://www.helloretail.com",
"en-GB": "https://www.helloretail.com",
"de-DE": "https://www.helloretail.com"
},
"supportLink": {
"da-DK": "https://www.wexo.dk/shopware-support",
"en-GB": "https://www.wexo.dk/shopware-support",
"de-DE": "https://www.wexo.dk/shopware-support"
}
}
}
35 changes: 35 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
version: "3.3"
services:
shopware:
image: ghcr.io/helloretail/shopware6-extension/shopware:1.4
container_name: shopware
environment:
APP_ENV: dev
networks:
- dev-env
restart: unless-stopped
volumes:
- shopware:/usr/app/src
- ./docker-config/shopware6/virtualhosts.conf:/etc/apache2/sites-available/shopware.hrdev.test.conf
shopwaredb:
restart: unless-stopped
container_name: shopwaredb
networks:
- dev-env
image: ghcr.io/helloretail/shopware6-extension/shopwaredb:1.4
volumes:
- db:/var/lib/mysql
environment:
- MARIADB_ROOT_PASSWORD=addwishdev
- MARIADB_USER=addwish
- MARIADB_PASSWORD=addwishdev
- MARIADB_ALLOW_EMPTY_PASSWORD=true
- MYSQL_DATABASE=shopware
volumes:
shopware:
db:

networks:
dev-env:
external: true

4 changes: 4 additions & 0 deletions docker-config/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
login to admin interface is

username: admin
password: HelloRetail!
10 changes: 10 additions & 0 deletions docker-config/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#! /bin/bash

TAG=$1

mkdir -p exports
docker cp shopware:/usr/app/src ./exports/shopware
docker build -t ghcr.io/helloretail/shopware6-extension/shopware:$TAG -f docker-config/shopware6/Dockerfile .
docker cp shopwaredb:/var/lib/mysql ./exports/shopwaredb
docker build -t ghcr.io/helloretail/shopware6-extension/shopwaredb:$TAG -f docker-config/shopwaredb/Dockerfile .
rm -r ./exports
34 changes: 34 additions & 0 deletions docker-config/shopware6/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
FROM debian:12-slim as build

WORKDIR /usr/app/src

RUN apt update && \
apt install curl php php-fpm supervisor screen -y

RUN apt install -y composer php-curl apache2 php-dom php-fileinfo php-gd php-iconv php-intl php-json php-xml php-mbstring pcregrep php-pdo php-mysql php-phar php-simplexml php-xml php-zip zlib1g-dev vim && a2enmod rewrite

ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR "/var/log/apache"
ENV CFLAGS "-DBIG_SECURITY_HOLE"
ENV APACHE_PID_FILE /var/run/apache2/apache2$SUFFIX.pid
COPY docker-config/shopware6/shopware-installer.phar.php .
COPY docker-config/shopware6/virtualhosts.conf /etc/apache2/sites-available/shopware.hrdev.test.conf
RUN ln -s /etc/apache2/sites-available/shopware.hrdev.test.conf /etc/apache2/sites-enabled/
RUN sed -i "s/;opcache.memory_consumption=128/opcache.memory_consumption=256/g" /etc/php/8.2/apache2/php.ini
RUN sed -i "s/memory_limit = 128M/memory_limit = 512M/g" /etc/php/8.2/apache2/php.ini
RUN chown -R www-data:www-data /usr/app/src && chown -R www-data:www-data /var/log/apache2 && chown -R www-data:www-data /var/run/apache2
RUN touch /var/log/DEV.log && touch /var/log/PROD.log && chown www-data:www-data /var/log/PROD.log && chown www-data:www-data /var/log/DEV.log

CMD ["apache2ctl", "-DFOREGROUND"]

FROM build

COPY --chown=www-data:www-data exports/shopware /usr/app/src
COPY --chown=www-data:www-data docker-config/shopware6/entrypoint.sh .
RUN chown -R www-data:www-data /usr/app/src

USER www-data:www-data

ENTRYPOINT ["./entrypoint.sh"]
CMD ["apache2ctl", "-DFOREGROUND"]
4 changes: 4 additions & 0 deletions docker-config/shopware6/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#! /bin/bash
echo starting entrypoint
sed -i "s/'https:\/\/d1pna5l3xsntoj.cloudfront.net\/scripts\/company\/awAddGift.js#{{ addWishPartnerId }}';/'https:\/\/d1pna5l3xsntoj.cloudfront.net\/scripts\/company\/awAddGift.js#{{ addWishPartnerId }},server_host=https:\/\/addwish.test,cdn_host=https:\/\/d1pna5l3xsntoj.cloudfront.test,core_host=https:\/\/core.helloretail.test,dashboard_host=https:\/\/my.helloretail.test';/g" /usr/app/src/custom/plugins/HelloRetail/src/Resources/views/storefront/component/hello-retail-tracking.html.twig
exec $@
Binary file not shown.
16 changes: 16 additions & 0 deletions docker-config/shopware6/virtualhosts.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<VirtualHost *:80>
ServerName "shopware.hrdev.test"
DocumentRoot /usr/app/src/public

<Directory /usr/app/src>
Options Indexes FollowSymLinks MultiViews
Require all granted
AllowOverride All
Order allow,deny
allow from all
</Directory>

ErrorLog ${APACHE_LOG_DIR}/shopware-platform.error.log
CustomLog ${APACHE_LOG_DIR}/shopware-platform.access.log combined
LogLevel debug
</VirtualHost>
3 changes: 3 additions & 0 deletions docker-config/shopwaredb/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM mariadb:10.4

COPY ./exports/shopwaredb /var/lib/mysql
85 changes: 85 additions & 0 deletions src/Command/GenerateFeed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?php declare(strict_types=1);

namespace Helret\HelloRetail\Command;

use Helret\HelloRetail\Service\ExportService;
use Shopware\Core\Framework\Context;
use Shopware\Core\Framework\DataAbstractionLayer\EntityRepositoryInterface;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Criteria;
use Shopware\Core\Framework\DataAbstractionLayer\Search\Filter\EqualsFilter;
use Shopware\Core\Framework\Routing\Exception\SalesChannelNotFoundException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Helret\HelloRetail\Export\Profiles\ProfileExporterInterface;
use Helret\HelloRetail\HelretHelloRetail;

/**
* Class GenerateFeed
* @package Helret\HelloRetail\Command
*/
class GenerateFeed extends Command
{
protected static $defaultName = 'hello-retail:generate-feed';
protected ProfileExporterInterface $profileExporter;
protected EntityRepositoryInterface $salesChannelRepository;

/**
* GenerateFeed constructor.
* @param ProfileExporterInterface $profileExporter
* @param EntityRepositoryInterface $salesChannelRepository
*/
public function __construct(
ProfileExporterInterface $profileExporter,
EntityRepositoryInterface $salesChannelRepository
) {
$this->profileExporter = $profileExporter;
$this->salesChannelRepository = $salesChannelRepository;

parent::__construct();
}

protected function configure(): void
{
$this->setDescription('Generates all configured Hello Retail feeds')
->addOption('feed', 'f', InputOption::VALUE_REQUIRED, 'Specific feed to generate')
->addOption("salesChannelId", "s", InputOption::VALUE_REQUIRED, "Generate for specific salesChannel");
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return int
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$feed = $input->getOption('feed');

$salesChannelId = $input->getOption('salesChannelId') ? [$input->getOption('salesChannelId')] : null;
$salesChannelIds = $this->salesChannelRepository->searchIds(
ExportService::getSalesChannelCriteria($salesChannelId),
Context::createDefaultContext()
)->getIds();

foreach ($salesChannelIds as $salesChannelId) {
try {
$this->profileExporter->generate($salesChannelId, $feed ? [$feed] : []);
$output->writeln("Feed(s) for sales channel: $salesChannelId were queued for generation");
} catch (\Error|\TypeError|\Exception|SalesChannelNotFoundException $exception) {
$msg = "Msg: {$exception->getMessage()}, ln: {$exception->getLine()}, File: {$exception->getFile()}";
$output->writeln($msg);
}
}

if (!$salesChannelIds) {
$output->writeln([
"No active sales channel(s) with type id: were found",
HelretHelloRetail::SALES_CHANNEL_TYPE_HELLO_RETAIL . PHP_EOL,
"Therefore skipping feed generation" . PHP_EOL
]);
}

return 0;
}
}
42 changes: 42 additions & 0 deletions src/Component/MessageQueue/HelloRetailExport.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php declare(strict_types=1);

namespace Helret\HelloRetail\Component\MessageQueue;

use Helret\HelloRetail\Export\ExportEntityInterface;

/**
* Class HelloRetailExport
* @package Helret\HelloRetail\Component\MessageQueue
*/
class HelloRetailExport
{
protected ExportEntityInterface $exportEntity;
protected string $feed;

/**
* HelloRetailExport constructor.
* @param ExportEntityInterface $exportEntity
* @param string $feed
*/
public function __construct(ExportEntityInterface $exportEntity, string $feed)
{
$this->exportEntity = $exportEntity;
$this->feed = $feed;
}

/**
* @return ExportEntityInterface
*/
public function getExportEntity(): ExportEntityInterface
{
return $this->exportEntity;
}

/**
* @return string
*/
public function getFeed(): string
{
return $this->feed;
}
}
Loading

0 comments on commit 9bd55fc

Please sign in to comment.