Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #16

Merged
merged 47 commits into from
Nov 8, 2021
Merged

Dev #16

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d9399ea
Merge pull request #11 from Jelmer-Ketelaar/master
Jelmer-Ketelaar Oct 29, 2021
4a1aab6
Merge pull request #14 from Jelmer-Ketelaar/master
Jelmer-Ketelaar Oct 30, 2021
8b23412
Added some styling to the page
Jelmer-Ketelaar Oct 30, 2021
85ea0a0
Added min-height to meal image
Jelmer-Ketelaar Oct 30, 2021
5aef9c2
Created a Product entity
Jelmer-Ketelaar Oct 31, 2021
a07d490
Merge branch 'development' of https://github.com/Jelmer-Ketelaar/gran…
Jelmer-Ketelaar Oct 31, 2021
dc5d8e9
Added ProducCcommand with not yet working code
Jelmer-Ketelaar Oct 31, 2021
b0714b9
Fixed error
Jelmer-Ketelaar Oct 31, 2021
ef62fb6
Updated files
Jelmer-Ketelaar Nov 1, 2021
3ba14bc
Added the functionality to see the right wines by the meal
Jelmer-Ketelaar Nov 1, 2021
5932465
Create README.md
Jelmer-Ketelaar Nov 1, 2021
0f4e168
Update style.css
Jelmer-Ketelaar Nov 1, 2021
66f7f85
Update style.css
Jelmer-Ketelaar Nov 2, 2021
d4b60f5
Update index.html.twig
Jelmer-Ketelaar Nov 2, 2021
ff14121
Styling info button as designed
Kingston02 Nov 2, 2021
518f600
Merge branch 'development' of https://github.com/Jelmer-Ketelaar/gran…
Kingston02 Nov 2, 2021
ba1560f
Added styling
Kingston02 Nov 2, 2021
7e82216
Update .env
Kingston02 Nov 2, 2021
9b35ea3
Merge branch 'dev' into #64
Kingston02 Nov 2, 2021
742432c
Merge pull request #15
Kingston02 Nov 2, 2021
612d6d5
styling sub categories page
Kingston02 Nov 2, 2021
c3a7ffc
updated style sub category
Kingston02 Nov 2, 2021
0f40122
Update index.html.twig
Jelmer-Ketelaar Nov 2, 2021
9a829ba
Added styling for meals
Jelmer-Ketelaar Nov 2, 2021
8317c2e
Landing page updated style and icons
Kingston02 Nov 2, 2021
6e06ab5
Merge branch 'dev' of https://github.com/Jelmer-Ketelaar/grandcruwijn…
Kingston02 Nov 2, 2021
d46b9cd
Added a score button and the styling for that
JurrijnModderman Nov 2, 2021
94660c7
Merge branch 'dev' of https://github.com/Jelmer-Ketelaar/grandcruwijn…
JurrijnModderman Nov 2, 2021
57e9717
Changed the styling
JurrijnModderman Nov 2, 2021
5aa9889
added stock amount to info
Kingston02 Nov 2, 2021
d3ea83e
Changed styling
JurrijnModderman Nov 2, 2021
fe98f62
Merge branch 'dev' of https://github.com/Jelmer-Ketelaar/grandcruwijn…
JurrijnModderman Nov 2, 2021
c731366
Added the functionality for the sommelier rating and tried to add the…
JurrijnModderman Nov 2, 2021
971933c
Scores format(0)
JurrijnModderman Nov 2, 2021
9330e84
Trying to add images to database in Command
Jelmer-Ketelaar Nov 2, 2021
3df0d23
Cleaned up code and fixed a bit of styling
Jelmer-Ketelaar Nov 2, 2021
d8c4fe7
Fixed images
Jelmer-Ketelaar Nov 2, 2021
7bc3edd
Changed text
JurrijnModderman Nov 3, 2021
bc46036
Fixed styling
Jelmer-Ketelaar Nov 3, 2021
3bc8731
Merge branch 'dev' of https://github.com/Jelmer-Ketelaar/grandcruwijn…
JurrijnModderman Nov 3, 2021
0a17ed7
Changed styling
Jelmer-Ketelaar Nov 3, 2021
76de31f
Added stock
Jelmer-Ketelaar Nov 3, 2021
9c3e679
Db description implement. Twig updated raw
Kingston02 Nov 3, 2021
23e3bc8
Merge branch 'dev' of https://github.com/Jelmer-Ketelaar/grandcruwijn…
JurrijnModderman Nov 3, 2021
6664d90
Rounded the score
JurrijnModderman Nov 4, 2021
2ee8258
Added price to the view
JurrijnModderman Nov 8, 2021
ae3e8c8
Merge branch 'master' into dev
KawianW Nov 8, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ APP_SECRET=86f8e46e16865da05c3cbe1137e8aa22
# IMPORTANT: You MUST configure your server version, either here or in config/packages/doctrine.yaml
#
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
DATABASE_URL="mysql://root:@127.0.0.1:3306/symfony"
DATABASE_URL="mysql://root:root@127.0.0.1:3306/symfony"
#DATABASE_URL="postgresql://db_user:[email protected]:3306/db_name?serverVersion=13&charset=utf8"
###< doctrine/doctrine-bundle ###

Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
1. composer install
2. bin/console doctrine:migrations:migrate
3. php -d memory_limit=-1 bin/console app:fill:products
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
"doctrine/doctrine-migrations-bundle": "^3.1",
"doctrine/orm": "^2.10",
"doctrine/sql-formatter": "^1.1",
"guzzlehttp/guzzle": "^6.5",
"grandcruwijnen/sdk": "^0.1.26",
"guzzlehttp/guzzle": "^6.5",
"nelmio/cors-bundle": "^2.1",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^6.1",
Expand Down
256 changes: 128 additions & 128 deletions composer.lock

Large diffs are not rendered by default.

19 changes: 18 additions & 1 deletion config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Files in the packages/ subdirectory configure your dependencies.

# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
# https://symfony.com/doc/current/best_practices/configuration.html#application-related-configuration
parameters:

services:
Expand All @@ -20,6 +20,23 @@ services:
- '../src/Entity/'
- '../src/Kernel.php'
- '../src/Tests/'
- '../src/Migrations/'

# controllers are imported separately to make sure services can be injected
# as action arguments even if you don't extend any base controller class
App\Controller\:
resource: '../src/Controller/'
tags: ['controller.service_arguments']

# add more service definitions when explicit configuration is needed
# please note that last definitions always *replace* previous ones
Grandcruwijnen\:
autowire: true
resource: '../vendor/grandcruwijnen/sdk/src/Grandcruwijnen/*'

Grandcruwijnen\SDK\API:
arguments:
$username: '%env(MAGENTO2_USERNAME)%'
$password: '%env(MAGENTO2_PASSWORD)%'
$baseUri: 'https://beta.grandcruwijnen.dev/'
$userAgent: 'Grandcruwijnen.nl Funnel'
Binary file added public/image/sommelierIcon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/image/wijnoverzicht.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/javascript/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
function goBack() {
window.history.back();
}
81 changes: 77 additions & 4 deletions public/style/style.css
Original file line number Diff line number Diff line change
@@ -1,10 +1,21 @@
body {
font-family: 'Montserrat', sans-serif;
height: 100%;
width: 100%;
background-color: #e9dcd1;
}

.example-wrapper {
margin: 1em auto;
max-width: 800px;
width: 95%;
font: 18px/1.5 sans-serif;
}

.example-wrapper code {
background: #F5F5F5;
padding: 2px 6px;
}

.p {
line-height: 1.5;
}
Expand All @@ -13,13 +24,25 @@ body {
display: inline-grid;
border: #1111 1px solid;
box-shadow: 0 0 5px -1px rgb(0 0 0 / 30%), 0 0 15px -1px rgb(0 0 0 / 25%), 0 0 20px -1px rgb(0 0 0 / 15%);
margin: 4vw 0 0 4vw;
margin: 4vw 0 0 4.5vw;
height: 25vh;
width: 20vh;
border-radius: 10%;
background-color: #e9dcd1;
}

.grid-sub {
display: inline-grid;
text-align: center;
border: #1111 1px solid;
box-shadow: 0 0 5px -1px rgb(0 0 0 / 30%), 0 0 15px -1px rgb(0 0 0 / 25%), 0 0 20px -1px rgb(0 0 0 / 15%);
margin: 4vw 0 0 4.5vw;
height: 60px;
width: 20vh;
border-radius: 10px;
background-color: #e9dcd1;
}

.grid:active {
box-shadow: 0 0 5px -1px rgb(0 0 0 / 30%), 0 0 15px -1px rgb(0 0 0 / 25%), 0 0 20px -1px rgb(0 0 0 / 15%);
transform: translateY(10px) translateX(10px);
Expand All @@ -40,10 +63,60 @@ body {
.text {
margin-left: 2vw;
}

h1 {
font-size: 4rem;
}

.container {
margin-top: 5000000vh !important;
.logo_landing_page {
margin: 30px 30px 30px 5vw;
}

.logo {
margin: 30px 30px 30px -10vw;

}

.content {
height: 100vh !important;
}

.mealImage {
/*margin: -10px;*/
width: 19.6vw;
margin-left: -15px;
border-radius: 20px 20px 0 0;
min-height: 20vw
}

#row {
display: flex;
width: 100%;
flex-wrap: wrap;
justify-content: center;
}

button {
outline: none !important;
}

#column {
text-align: center;
border-radius: 20px;
margin: 10px;
width: 20%;
height: 54vh;
box-shadow: rgba(0, 0, 0, 0.24) 0 3px 8px;
}

.wineImage {
max-width: 40vw;
max-height: 60vh;
position: relative;
padding-top: 5vh
}

.imageWine {
max-width: 200px;
max-height: 200px;
}
95 changes: 95 additions & 0 deletions src/Command/ProductsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?php

namespace App\Command;


use App\Entity\Product;
use App\Repository\ProductRepository;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Grandcruwijnen\SDK\Products;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class ProductsCommand extends Command {
protected static $defaultName = 'app:fill:products';
protected static $defaultDescription = 'Fills products database';

private Products $products;
private EntityManagerInterface $manager;
private ProductRepository $productRepository;

/**
* ProductsCommand constructor.
* @param Products $products
* @param EntityManagerInterface $manager
* @param ProductRepository $productRepository
*/
public function __construct(Products $products, EntityManagerInterface $manager, ProductRepository $productRepository)
{
parent::__construct();

$this->products = $products;
$this->manager = $manager;
$this->productRepository = $productRepository;
}

protected function configure(): void
{
$this->setDescription(self::$defaultDescription);
}

/**
* @throws Exception
* @throws GuzzleException
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$items = $this->products->getProducts()['items'];
foreach ($items as $magentoProduct)
{
//var_dump($magentoProduct['custom_attributes']); die();
if ($magentoProduct['status'] !== 1)
{
continue;
}
if ( ! isset($magentoProduct['media_gallery_entries'][0]))
{
continue;
}
$product = $this->productRepository->findOneBy(['sku' => $magentoProduct['sku']]);
$updatedAt = new DateTime($magentoProduct['updated_at']);
// $io->comment($magentoProduct['sku']);
if ($product === null)
{
$product = new Product();
$product
->setSku($magentoProduct['sku'])
->setUpdatedAt($updatedAt)
->setName($magentoProduct['name'])
->setDescription($magentoProduct['custom_attributes'][1]['value'])
->setPrice($magentoProduct["price"])
->setStock($magentoProduct['extension_attributes']['stock_item']['qty'])
->setImage($magentoProduct['media_gallery_entries'][0]['file']);
} else if ($updatedAt > $product->getUpdatedAt())
{
$product
->setValid(false)
->setCheckedSinceUpdate(false);
}

$this->manager->persist($product);
}

$this->manager->flush();

$io->success('Product database updated');

return Command::SUCCESS;
}
}
35 changes: 23 additions & 12 deletions src/Controller/MealController.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

namespace App\Controller;


use App\Dto\ProductMatch;
use App\Repository\ProductRepository;
use App\Service\MealMatcherService;
use Grandcruwijnen\SDK\API;
use Grandcruwijnen\SDK\Products;
use GuzzleHttp\Exception\GuzzleException;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -15,10 +14,13 @@
class MealController extends AbstractController
{

/**
* @throws GuzzleException
*/
#[Route('/', name: 'landing_page')]
public function getIndex(MealMatcherService $mealMatcherService): Response
{
return $this->render('landing page/index.html.twig', ['choices' => $mealMatcherService->getIndexPage()]);
return $this->render('landing/index.html.twig', ['choices' => $mealMatcherService->getIndexPage()]);
}

/**
Expand All @@ -33,7 +35,7 @@ public function getMealCategories(MealMatcherService $mealMatcherService): Respo
/**
* @throws GuzzleException
*/
#[Route('/{parentId}', name: 'meal_categories_for_parent')]
#[Route('/category/{parentId}', name: 'meal_categories_for_parent')]
public function getCategoriesForParent(int $parentId, MealMatcherService $mealMatcherService): Response
{
return $this->render('categories/index.html.twig', ['meals' => $mealMatcherService->getCategoriesForParent($parentId)]);
Expand All @@ -51,17 +53,26 @@ public function getMealsForCategory(int $categoryId, MealMatcherService $mealMat
/**
* @throws GuzzleException
*/
#[Route('/matches/{mealId}', name: 'wines_for_meals')]
public function getWinesForMeals($mealId, MealMatcherService $mealMatcherService)
#[Route('matches/{mealId}', name: 'wines_for_meals')]
public function getWinesForMeals(ProductRepository $products, $mealId, MealMatcherService $mealMatcherService): Response
{
$matches = [];
// dd($mealMatcherService->getWinesForMeal($mealId));
foreach ($mealMatcherService->getWinesForMeal($mealId) as $wine) {
$product = $products->findOneBy(['sku' => $wine->wine->sku]);
// $product = $products->findOneBy(['sku' => $wine->wine->sku]);
if ($product !== null) {
$score = $wine->score;
$productMatch = new ProductMatch($product, $score);
$matches[] = $productMatch;
// $score'' = $product;

$api = new API("[email protected]", "7Wn2okY7!A@mX-DZMmw7tanFaQ*sTGef87o!Gn4_mE6ctiqmLk2hH6LX_deN_K8P7U6LRs7H2BT.cGWvh", "https://beta.grandcruwijnen.dev");
$products = new Products($api);
$sku = '01001';
$products = $products->getProduct($sku);
//TODO: Scores toevoegen aan de wijn
}
}

return $this->render('wines/index.html.twig', [
'products' => $products, 'matches' => $mealMatcherService->getWinesForMeal($mealId)
'matches' => $matches
]);
}
}
14 changes: 14 additions & 0 deletions src/Dto/ProductMatch.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

namespace App\Dto;

class ProductMatch {
public $product;
public $score;
public function __construct ($product, $score) {
$this->product = $product;
$this->score = $score;
}
}

?>
Loading