SlideShare a Scribd company logo
1 of 15
Download to read offline
Magento 2.x
Samo życie
Kamil Balwierz
● 17 listopad 2015
● 228 000 pobrań
● 800 sklepów online
Frontend
● minifikacja HTML
● jQuery
● RequireJS
● Knockout
● LESS
Bez Varnish
Varnish + ESI
Varnish + Knockout
HTML 500ms
HTML 350msHTML 50ms +
HTML 50ms
JSON 350ms
(pobierz tylko raz)
Frontend
● minifikacja HTML
● jQuery
● RequireJS
● Knockout
● LESS
SnowdogApps/magento2-frontools
SnowdogApps/magento2-theme-blank-sass
Backend Magento 2
● composer
● Magento Marketplace
● Zend Framework
● Zend Framework 2
● Symfony
● magento/framework
Service Contracts
● interface PHP
● @api
<?php



namespace MagentoCatalogApi;



/**

* @api

*/

interface ProductRepositoryInterface

{

/**

* Create product

*

* @param MagentoCatalogApiDataProductInterface $product

* @param bool $saveOptions

* @return MagentoCatalogApiDataProductInterface

* @throws MagentoFrameworkExceptionInputException

* @throws MagentoFrameworkExceptionStateException

* @throws MagentoFrameworkExceptionCouldNotSaveException

*/

public function save(MagentoCatalogApiDataProductInterface $product, $saveOptions = false);



/**

* Get info about product by product SKU

*

* @param string $sku

* @param bool $editMode

* @param int|null $storeId

* @param bool $forceReload

* @return MagentoCatalogApiDataProductInterface

* @throws MagentoFrameworkExceptionNoSuchEntityException

*/

public function get($sku, $editMode = false, $storeId = null, $forceReload = false);



/**

* Get info about product by product id

*

* @param int $productId

* @param bool $editMode

* @param null|int $storeId

* @param bool $forceReload

* @return MagentoCatalogApiDataProductInterface

* @throws MagentoFrameworkExceptionNoSuchEntityException

*/

public function getById($productId, $editMode = false, $storeId = null, $forceReload = false);



/**

* Delete product

*

* @param MagentoCatalogApiDataProductInterface $product

* @return bool Will returned True if deleted

* @throws MagentoFrameworkExceptionStateException

*/

<?php



namespace MagentoCatalogApiData;



/**

* @api

*/

interface ProductInterface extends MagentoFrameworkApiCustomAttributesDataInterface

{

/**

* Product id

*

* @return int|null

*/

public function getId();



/**

* Product sku

*

* @return string

*/

public function getSku();



/**

* Product name

*

* @return string|null

*/

public function getName();



Dependency Injection
● wstrzyknięcie konstruktorem
● minimalna konfiguracja
<?php



namespace TrainingFlatIndexerModelResourceModelFlat;



use TrainingFlatIndexerModelResourceModelContext;

use TrainingFlatIndexerModelResourceModelMetadata;



class TableBuilder

{

/**

* @var Metadata

*/

private $metadata;



/**

* @var Context

*/

private $context;



/**

* TableBuilder constructor.

* @param Metadata $metadata

* @param Context $context

*/

public function __construct(Metadata $metadata, Context $context)

{

$this->metadata = $metadata;

$this->context = $context;

}



public function validateTable()

{

$this->validateTableByName($this->context->getIndexTable());

return $this;

}



public function switchTable()

{

$this->context->toggleTable();

return $this;

}
Object Manager
● Interceptory
● klasy Proxy
● typy wirtualne
<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">



<virtualType name="contextCategory" type="TrainingFlatIndexerModelResourceModelContext">

<arguments>

<argument name="indexerCode" xsi:type="string">training_flat_index_category</argument>

<argument name="entity" xsi:type="string">catalog_category</argument>

</arguments>

</virtualType>



<virtualType name="metadataCategory" type="TrainingFlatIndexerModelResourceModelMetadata">

<arguments>

<argument name="context" xsi:type="object">contextCategory</argument>

<argument name="systemAttributeCodes" xsi:type="array">

<item name="path" xsi:type="string">path</item>

<item name="parent_id" xsi:type="string">parent_id</item>

</argument>

</arguments>

</virtualType>



<virtualType name="tableBuilderCategory" type="TrainingFlatIndexerModelResourceModelFlatTableBuilder">

<arguments>

<argument name="context" xsi:type="object">contextCategory</argument>

<argument name="metadata" xsi:type="object">metadataCategory</argument>

</arguments>

</virtualType>



<virtualType name="tablePopulatorCategory" type="TrainingFlatIndexerModelResourceModelFlatTablePopulator">

<arguments>

<argument name="context" xsi:type="object">contextCategory</argument>

<argument name="metadata" xsi:type="object">metadataCategory</argument>

</arguments>

</virtualType>



<virtualType name="trainingFlatIndexerCategory" type="TrainingFlatIndexerModelIndexerFlat">

<arguments>

<argument name="tableBuilder" xsi:type="object">tableBuilderCategory</argument>

<argument name="tablePopulator" xsi:type="object">tablePopulatorCategory</argument>

</arguments>

</virtualType>



<type name="TrainingFlatIndexerModelResourceModelMetadata">

<arguments>

<argument name="systemAttributeCodes" xsi:type="array">

<item name="status" xsi:type="string">status</item>

<item name="visibility" xsi:type="string">visibility</item>

<item name="type_id" xsi:type="string">type_id</item>

<item name="attribute_set_id" xsi:type="string">attribute_set_id</item>

<item name="required_options" xsi:type="string">required_options</item>

</argument>

</arguments>

WebAPI
● REST
● swagger
● SOAP
● automatyczne WSDL
● AMPQ (RabbitMQ w Magento 2 Enterprise)
Alan Kent
Główny architekt Magento
https://alankent.me/
Alan Storm
Freelancer, konsultant, twórca CommerceBug
http://alanstorm.com/category/magento-2
Dokumentacja Magento 2
http://devdocs.magento.com/
Magento na StackExchange
http://magento.stackexchange.com/
Dziękuje za uwagę!
kamil@snow.dog
@mamut144

More Related Content

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Magento 2.x. Samo życie.

  • 2.
  • 3. ● 17 listopad 2015 ● 228 000 pobrań ● 800 sklepów online
  • 4. Frontend ● minifikacja HTML ● jQuery ● RequireJS ● Knockout ● LESS
  • 5. Bez Varnish Varnish + ESI Varnish + Knockout HTML 500ms HTML 350msHTML 50ms + HTML 50ms JSON 350ms (pobierz tylko raz)
  • 6. Frontend ● minifikacja HTML ● jQuery ● RequireJS ● Knockout ● LESS
  • 9. Backend Magento 2 ● composer ● Magento Marketplace ● Zend Framework ● Zend Framework 2 ● Symfony ● magento/framework
  • 10. Service Contracts ● interface PHP ● @api <?php
 
 namespace MagentoCatalogApi;
 
 /**
 * @api
 */
 interface ProductRepositoryInterface
 {
 /**
 * Create product
 *
 * @param MagentoCatalogApiDataProductInterface $product
 * @param bool $saveOptions
 * @return MagentoCatalogApiDataProductInterface
 * @throws MagentoFrameworkExceptionInputException
 * @throws MagentoFrameworkExceptionStateException
 * @throws MagentoFrameworkExceptionCouldNotSaveException
 */
 public function save(MagentoCatalogApiDataProductInterface $product, $saveOptions = false);
 
 /**
 * Get info about product by product SKU
 *
 * @param string $sku
 * @param bool $editMode
 * @param int|null $storeId
 * @param bool $forceReload
 * @return MagentoCatalogApiDataProductInterface
 * @throws MagentoFrameworkExceptionNoSuchEntityException
 */
 public function get($sku, $editMode = false, $storeId = null, $forceReload = false);
 
 /**
 * Get info about product by product id
 *
 * @param int $productId
 * @param bool $editMode
 * @param null|int $storeId
 * @param bool $forceReload
 * @return MagentoCatalogApiDataProductInterface
 * @throws MagentoFrameworkExceptionNoSuchEntityException
 */
 public function getById($productId, $editMode = false, $storeId = null, $forceReload = false);
 
 /**
 * Delete product
 *
 * @param MagentoCatalogApiDataProductInterface $product
 * @return bool Will returned True if deleted
 * @throws MagentoFrameworkExceptionStateException
 */
 <?php
 
 namespace MagentoCatalogApiData;
 
 /**
 * @api
 */
 interface ProductInterface extends MagentoFrameworkApiCustomAttributesDataInterface
 {
 /**
 * Product id
 *
 * @return int|null
 */
 public function getId();
 
 /**
 * Product sku
 *
 * @return string
 */
 public function getSku();
 
 /**
 * Product name
 *
 * @return string|null
 */
 public function getName();
 

  • 11. Dependency Injection ● wstrzyknięcie konstruktorem ● minimalna konfiguracja <?php
 
 namespace TrainingFlatIndexerModelResourceModelFlat;
 
 use TrainingFlatIndexerModelResourceModelContext;
 use TrainingFlatIndexerModelResourceModelMetadata;
 
 class TableBuilder
 {
 /**
 * @var Metadata
 */
 private $metadata;
 
 /**
 * @var Context
 */
 private $context;
 
 /**
 * TableBuilder constructor.
 * @param Metadata $metadata
 * @param Context $context
 */
 public function __construct(Metadata $metadata, Context $context)
 {
 $this->metadata = $metadata;
 $this->context = $context;
 }
 
 public function validateTable()
 {
 $this->validateTableByName($this->context->getIndexTable());
 return $this;
 }
 
 public function switchTable()
 {
 $this->context->toggleTable();
 return $this;
 }
  • 12. Object Manager ● Interceptory ● klasy Proxy ● typy wirtualne <?xml version="1.0"?>
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
 
 <virtualType name="contextCategory" type="TrainingFlatIndexerModelResourceModelContext">
 <arguments>
 <argument name="indexerCode" xsi:type="string">training_flat_index_category</argument>
 <argument name="entity" xsi:type="string">catalog_category</argument>
 </arguments>
 </virtualType>
 
 <virtualType name="metadataCategory" type="TrainingFlatIndexerModelResourceModelMetadata">
 <arguments>
 <argument name="context" xsi:type="object">contextCategory</argument>
 <argument name="systemAttributeCodes" xsi:type="array">
 <item name="path" xsi:type="string">path</item>
 <item name="parent_id" xsi:type="string">parent_id</item>
 </argument>
 </arguments>
 </virtualType>
 
 <virtualType name="tableBuilderCategory" type="TrainingFlatIndexerModelResourceModelFlatTableBuilder">
 <arguments>
 <argument name="context" xsi:type="object">contextCategory</argument>
 <argument name="metadata" xsi:type="object">metadataCategory</argument>
 </arguments>
 </virtualType>
 
 <virtualType name="tablePopulatorCategory" type="TrainingFlatIndexerModelResourceModelFlatTablePopulator">
 <arguments>
 <argument name="context" xsi:type="object">contextCategory</argument>
 <argument name="metadata" xsi:type="object">metadataCategory</argument>
 </arguments>
 </virtualType>
 
 <virtualType name="trainingFlatIndexerCategory" type="TrainingFlatIndexerModelIndexerFlat">
 <arguments>
 <argument name="tableBuilder" xsi:type="object">tableBuilderCategory</argument>
 <argument name="tablePopulator" xsi:type="object">tablePopulatorCategory</argument>
 </arguments>
 </virtualType>
 
 <type name="TrainingFlatIndexerModelResourceModelMetadata">
 <arguments>
 <argument name="systemAttributeCodes" xsi:type="array">
 <item name="status" xsi:type="string">status</item>
 <item name="visibility" xsi:type="string">visibility</item>
 <item name="type_id" xsi:type="string">type_id</item>
 <item name="attribute_set_id" xsi:type="string">attribute_set_id</item>
 <item name="required_options" xsi:type="string">required_options</item>
 </argument>
 </arguments>

  • 13. WebAPI ● REST ● swagger ● SOAP ● automatyczne WSDL ● AMPQ (RabbitMQ w Magento 2 Enterprise)
  • 14. Alan Kent Główny architekt Magento https://alankent.me/ Alan Storm Freelancer, konsultant, twórca CommerceBug http://alanstorm.com/category/magento-2 Dokumentacja Magento 2 http://devdocs.magento.com/ Magento na StackExchange http://magento.stackexchange.com/