├── sample-module-payment-gateway ├── i18n │ └── en_US.csv ├── registration.php ├── etc │ ├── events.xml │ ├── module.xml │ ├── adminhtml │ │ └── di.xml │ ├── frontend │ │ └── di.xml │ └── config.xml ├── Model │ ├── Adminhtml │ │ └── Source │ │ │ └── PaymentAction.php │ └── Ui │ │ └── ConfigProvider.php ├── view │ └── frontend │ │ └── web │ │ └── js │ │ └── view │ │ └── payment │ │ ├── sample_gateway.js │ │ └── method-renderer │ │ └── sample_gateway.js ├── composer.json ├── Test │ └── Unit │ │ ├── Model │ │ ├── Adminhtml │ │ │ └── Source │ │ │ │ └── PaymentActionTest.php │ │ └── Ui │ │ │ └── ConfigProviderTest.php │ │ ├── Gateway │ │ ├── Response │ │ │ ├── TxnIdHandlerTest.php │ │ │ └── FraudHandlerTest.php │ │ ├── Http │ │ │ └── TransferFactoryTest.php │ │ └── Request │ │ │ ├── VoidRequestTest.php │ │ │ ├── CaptureRequestTest.php │ │ │ └── MockDataRequestTest.php │ │ └── Observer │ │ └── DataAssignObserverTest.php ├── Observer │ └── DataAssignObserver.php ├── Block │ └── Info.php └── Gateway │ ├── Response │ ├── TxnIdHandler.php │ └── FraudHandler.php │ ├── Request │ ├── MockDataRequest.php │ ├── AuthorizationRequest.php │ ├── VoidRequest.php │ └── CaptureRequest.php │ ├── Http │ └── TransferFactory.php │ └── Validator │ └── ResponseCodeValidator.php ├── sample-module-minimal ├── Test │ └── Unit │ │ └── README.md ├── registration.php ├── etc │ └── module.xml ├── composer.json └── README.md ├── sample-module-theme ├── media │ └── preview.jpg ├── web │ └── images │ │ └── logo.png ├── registration.php ├── theme.xml ├── composer.json └── Magento_Theme │ └── layout │ └── default.xml ├── sample-module-webapi-client ├── example.png ├── view │ └── frontend │ │ ├── requirejs-config.js │ │ ├── layout │ │ └── samplewebapiclient_index_index.xml │ │ ├── web │ │ └── js │ │ │ └── templates │ │ │ └── result.html │ │ └── templates │ │ ├── web_api_client.phtml │ │ └── filter.phtml ├── registration.php ├── etc │ ├── module.xml │ └── frontend │ │ └── routes.xml ├── composer.json ├── README.md └── Controller │ └── Index │ └── Index.php ├── sample-module-modifycontent ├── view │ └── frontend │ │ ├── web │ │ └── images │ │ │ └── logo.png │ │ ├── templates │ │ └── catalog_product_view_image.phtml │ │ └── layout │ │ └── catalog_product_view.xml ├── registration.php ├── etc │ └── module.xml └── composer.json ├── sample-module-newpage ├── view │ └── frontend │ │ ├── templates │ │ └── main.phtml │ │ └── layout │ │ └── newpage_index_index.xml ├── registration.php ├── etc │ ├── module.xml │ └── frontend │ │ └── routes.xml ├── composer.json ├── Test │ └── Unit │ │ └── IndexTest.php └── Controller │ └── Index │ └── Index.php ├── sample-module-servicecontract-new ├── view │ └── frontend │ │ ├── templates │ │ ├── main.phtml │ │ └── feed_list.phtml │ │ └── layout │ │ ├── newpage_index_index.xml │ │ └── sampleservicecontractnew_index_index.xml ├── registration.php ├── API │ ├── FeedListInterface.php │ ├── Data │ │ ├── FeedSearchResultInterface.php │ │ └── FeedInterface.php │ └── FeedRepositoryInterface.php ├── etc │ ├── module.xml │ ├── frontend │ │ └── routes.xml │ └── di.xml ├── composer.json ├── Model │ ├── SampleFeed.php │ ├── UrlBuilder.php │ ├── FeedList.php │ ├── FeedTransformer.php │ ├── Data │ │ └── Feed.php │ └── Feed.php ├── Test │ └── Unit │ │ ├── Model │ │ ├── SampleFeedTest.php │ │ ├── UrlBuilderTest.php │ │ └── Data │ │ │ └── FeedTest.php │ │ └── Controller │ │ └── Index │ │ └── IndexTest.php ├── Controller │ ├── Index │ │ └── Index.php │ └── Feed │ │ └── View.php └── Block │ └── FeedList.php ├── sample-module-webflow ├── view │ └── frontend │ │ ├── templates │ │ ├── nextpage.phtml │ │ └── firstpage.phtml │ │ └── layout │ │ ├── webflow_nextpage_index.xml │ │ └── webflow_firstpage_index.xml ├── registration.php ├── etc │ ├── module.xml │ └── frontend │ │ └── routes.xml ├── Test │ └── Unit │ │ ├── Controller │ │ ├── NextPage │ │ │ └── IndexTest.php │ │ ├── FirstPage │ │ │ └── IndexTest.php │ │ └── AbstractActionTest.php │ │ └── Block │ │ └── FirstPageTest.php ├── composer.json ├── Block │ └── FirstPage.php ├── Controller │ ├── NextPage │ │ └── Index.php │ └── FirstPage │ │ └── Index.php └── README.md ├── module-sample-scss ├── registration.php ├── view │ └── base │ │ └── web │ │ └── css │ │ ├── test.less │ │ └── test.scss ├── Test │ └── Unit │ │ └── Preprocessor │ │ └── Adapter │ │ └── Scss │ │ └── _files │ │ └── test.scss ├── etc │ ├── module.xml │ └── di.xml ├── composer.json ├── README.md └── Preprocessor │ └── Adapter │ └── Scss │ └── Processor.php ├── sample-external-links ├── registration.php ├── Api │ ├── ExternalLinksProviderInterface.php │ └── Data │ │ └── ExternalLinkInterface.php ├── etc │ ├── module.xml │ ├── extension_attributes.xml │ └── di.xml ├── composer.json ├── Model │ ├── ExternalLinks │ │ └── Provider.php │ └── ResourceModel │ │ └── ExternalLinks │ │ └── Loader.php └── Tests │ └── Unit │ └── Model │ └── ExternalLinks │ └── ProviderTest.php ├── sample-module-command ├── registration.php ├── composer.json ├── etc │ ├── module.xml │ └── di.xml ├── Test │ └── Unit │ │ └── Console │ │ └── Command │ │ ├── CheckActiveModulesCommandTest.php │ │ └── GreetingCommandTest.php └── Console │ └── Command │ ├── CheckActiveModulesCommand.php │ └── GreetingCommand.php ├── sample-module-form-uicomponent ├── registration.php ├── etc │ ├── module.xml │ └── adminhtml │ │ └── routes.xml ├── view │ └── adminhtml │ │ ├── web │ │ ├── template │ │ │ └── form │ │ │ │ └── element │ │ │ │ └── color-select.html │ │ ├── css │ │ │ └── color-select.css │ │ └── js │ │ │ └── form │ │ │ └── element │ │ │ └── color-select.js │ │ └── layout │ │ └── sampleform_index_index.xml ├── Model │ └── DataProvider.php ├── composer.json └── Controller │ └── Adminhtml │ └── Index │ └── Index.php ├── sample-module-interception ├── registration.php ├── etc │ ├── module.xml │ ├── frontend │ │ └── routes.xml │ └── di.xml ├── Model │ ├── Intercepted │ │ ├── ChildAfter.php │ │ ├── ChildInherit.php │ │ ├── ChildAround.php │ │ └── ChildBefore.php │ └── Intercepted.php ├── composer.json ├── view │ └── frontend │ │ └── layout │ │ └── sampleinterception_index_index.xml ├── Test │ └── Unit │ │ ├── Plugin │ │ ├── PluginAfterTest.php │ │ ├── PluginBeforeTest.php │ │ ├── ParentPluginTest.php │ │ └── PluginAroundTest.php │ │ ├── Model │ │ └── InterceptedTest.php │ │ ├── Controller │ │ └── Index │ │ │ └── IndexTest.php │ │ └── Block │ │ └── PageTest.php ├── Plugin │ ├── ParentPlugin.php │ ├── PluginAfter.php │ ├── PluginBefore.php │ └── PluginAround.php └── Controller │ └── Index │ └── Index.php ├── sample-module-sample-message-queue ├── registration.php ├── etc │ ├── module.xml │ ├── communication.xml │ ├── di.xml │ └── queue.xml ├── README.md ├── composer.json ├── Model │ └── Handler │ │ └── Async │ │ └── GiftCardAddedSuccess.php └── LICENSE_MIT.txt ├── sample-module-shipping-provider ├── registration.php ├── etc │ ├── module.xml │ └── config.xml ├── view │ └── frontend │ │ ├── web │ │ └── js │ │ │ ├── model │ │ │ ├── shipping-rates-validation-rules.js │ │ │ └── shipping-rates-validator.js │ │ │ └── view │ │ │ └── shipping-rates-validation.js │ │ └── layout │ │ └── checkout_cart_index.xml ├── composer.json ├── Test │ └── Unit │ │ └── Block │ │ └── System │ │ └── Config │ │ └── Form │ │ └── Field │ │ └── LocationsTest.php ├── README.md └── Block │ └── System │ └── Config │ └── Form │ └── Field │ └── Locations.php ├── sample-module-service-contract-client ├── registration.php ├── etc │ ├── module.xml │ └── frontend │ │ └── routes.xml ├── composer.json ├── view │ └── frontend │ │ ├── layout │ │ └── servicecontractclient_index_index.xml │ │ └── templates │ │ └── service_contract_client.phtml ├── README.md └── Controller │ └── Index │ └── Index.php ├── sample-module-custom-deployment-config ├── registration.php ├── etc │ ├── module.xml │ └── di.xml ├── composer.json ├── Test │ └── Unit │ │ └── Console │ │ └── Command │ │ └── ShowCustomDeploymentConfigCommandTest.php └── Console │ └── Command │ └── ShowCustomDeploymentConfigCommand.php ├── sample-ee-bundle-all ├── composer.json ├── README.md └── LICENSE_MIT.txt ├── sample-module-service-contract-replacement ├── registration.php ├── etc │ ├── module.xml │ └── di.xml ├── composer.json ├── Model │ └── QuoteRepository.php └── README.md └── sample-bundle-all ├── README.md └── composer.json /sample-module-payment-gateway/i18n/en_US.csv: -------------------------------------------------------------------------------- 1 | "FRAUD_MSG_LIST","Fraud Messages" 2 | -------------------------------------------------------------------------------- /sample-module-minimal/Test/Unit/README.md: -------------------------------------------------------------------------------- 1 | Place your unit tests in this directory. 2 | -------------------------------------------------------------------------------- /sample-module-theme/media/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageplaza/magento2-samples/HEAD/sample-module-theme/media/preview.jpg -------------------------------------------------------------------------------- /sample-module-theme/web/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageplaza/magento2-samples/HEAD/sample-module-theme/web/images/logo.png -------------------------------------------------------------------------------- /sample-module-webapi-client/example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageplaza/magento2-samples/HEAD/sample-module-webapi-client/example.png -------------------------------------------------------------------------------- /sample-module-modifycontent/view/frontend/web/images/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mageplaza/magento2-samples/HEAD/sample-module-modifycontent/view/frontend/web/images/logo.png -------------------------------------------------------------------------------- /sample-module-newpage/view/frontend/templates/main.phtml: -------------------------------------------------------------------------------- 1 | 7 |

8 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/view/frontend/templates/main.phtml: -------------------------------------------------------------------------------- 1 | 7 |

8 | -------------------------------------------------------------------------------- /sample-module-webflow/view/frontend/templates/nextpage.phtml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /module-sample-scss/registration.php: -------------------------------------------------------------------------------- 1 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /sample-module-webflow/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample-module-webflow/view/frontend/templates/firstpage.phtml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 13 | 14 | -------------------------------------------------------------------------------- /sample-external-links/Api/ExternalLinksProviderInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-newpage/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /module-sample-scss/view/base/web/css/test.less: -------------------------------------------------------------------------------- 1 | // /** 2 | // * Copyright © 2016 Magento. All rights reserved. 3 | // * See COPYING.txt for license details. 4 | // */ 5 | 6 | /* Mixin */ 7 | .border-radius (@radius: 5px) { 8 | -webkit-border-radius: @radius; 9 | -moz-border-radius: @radius; 10 | border-radius: @radius; 11 | } 12 | 13 | /* Implementation */ 14 | #somediv { 15 | .border-radius(20px); 16 | } 17 | -------------------------------------------------------------------------------- /sample-module-interception/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /sample-module-command/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/API/FeedListInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-minimal/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | An extension to demonstrate sending and processing of synchronous/asynchronous queue messages. 4 | 5 | ## Motivation 6 | 7 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent is to learn by example, following our best practices for developing a modular site using Magento 2. 8 | 9 | ## Contributors 10 | 11 | Magento Core team 12 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/view/adminhtml/web/template/form/element/color-select.html: -------------------------------------------------------------------------------- 1 | 5 | 6 | -------------------------------------------------------------------------------- /sample-module-service-contract-replacement/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /module-sample-scss/view/base/web/css/test.scss: -------------------------------------------------------------------------------- 1 | // /** 2 | // * Copyright © 2016 Magento. All rights reserved. 3 | // * See COPYING.txt for license details. 4 | // */ 5 | 6 | $myColor: #009a82; 7 | $myString: "Test text"; 8 | $myFontSize: 13px; 9 | $myMargin: 0px auto; 10 | $myWidth: 460px; 11 | 12 | h1 { 13 | color: $myColor; 14 | margin: 0; 15 | padding: 0; 16 | } 17 | 18 | #container { 19 | width: $myWidth; 20 | margin: $myMargin; 21 | } 22 | -------------------------------------------------------------------------------- /sample-module-custom-deployment-config/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /sample-module-custom-deployment-config/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-custom-deployment-config", 3 | "description": "Custom deployment config option example", 4 | "type":"magento2-module", 5 | "require": { 6 | "php": "~5.5.0|~5.6.0|~7.0.0" 7 | }, 8 | "version": "1.0.0", 9 | "autoload": { 10 | "files": [ "registration.php" ], 11 | "psr-4": { 12 | "Magento\\CustomDeploymentConfigExample\\": "" 13 | } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sample-module-interception/Model/Intercepted/ChildAfter.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | eBay Blue 9 | Magento/luma 10 | 11 | media/preview.jpg 12 | 13 | 14 | -------------------------------------------------------------------------------- /module-sample-scss/Test/Unit/Preprocessor/Adapter/Scss/_files/test.scss: -------------------------------------------------------------------------------- 1 | // /** 2 | // * Copyright © 2016 Magento. All rights reserved. 3 | // * See COPYING.txt for license details. 4 | // */ 5 | 6 | $myColor: #009a82; 7 | $myString: "Test text"; 8 | $myFontSize: 13px; 9 | $myMargin: 0px auto; 10 | $myWidth: 460px; 11 | 12 | h1 { 13 | color: $myColor; 14 | margin: 0; 15 | padding: 0; 16 | } 17 | 18 | #container { 19 | width: $myWidth; 20 | margin: $myMargin; 21 | } 22 | -------------------------------------------------------------------------------- /module-sample-scss/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-minimal/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-minimal", 3 | "description": "A minimal skeleton Magento 2 module", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0" 12 | }, 13 | "autoload": { 14 | "files": [ "registration.php" ], 15 | "psr-4": { 16 | "Magento\\SampleMinimal\\": "" 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/view/adminhtml/web/css/color-select.css: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | 6 | .color-select{ 7 | padding-left:5px; 8 | } 9 | .color-select li { 10 | margin-right:5px; 11 | width:50px; 12 | height:50px; 13 | display: inline-block; 14 | cursor: pointer; 15 | cursor: hand; 16 | } 17 | .color-select li.selected { 18 | border: 2px solid dimgrey; 19 | } 20 | -------------------------------------------------------------------------------- /sample-external-links/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Magento/ExternalLinks", 3 | "description": "N/A", 4 | "require": { 5 | "php": "~5.6.0|7.0.2|~7.0.6" 6 | }, 7 | "type": "magento2-module", 8 | "version": "dev-master", 9 | "license": [ 10 | "proprietary" 11 | ], 12 | "autoload": { 13 | "files": [ 14 | "registration.php" 15 | ], 16 | "psr-4": { 17 | "Magento\\ExternalLinks\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/Model/DataProvider.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample-module-newpage/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-newpage", 3 | "description": "A Magento 2 module that creates a new page", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0" 13 | }, 14 | "autoload": { 15 | "files": [ "registration.php" ], 16 | "psr-4": { 17 | "Magento\\SampleNewPage\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-module-newpage/etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-webflow/Test/Unit/Controller/NextPage/IndexTest.php: -------------------------------------------------------------------------------- 1 | className = 'Magento\SampleWebFlow\Controller\NextPage\Index'; 13 | parent::setUp(); 14 | } 15 | } -------------------------------------------------------------------------------- /sample-module-interception/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-interception", 3 | "description": "Demonstrate plugin functionality", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0" 13 | }, 14 | "autoload": { 15 | "files": [ "registration.php" ], 16 | "psr-4": { 17 | "Magento\\SampleInterception\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-module-webflow/Test/Unit/Controller/FirstPage/IndexTest.php: -------------------------------------------------------------------------------- 1 | className = 'Magento\SampleWebFlow\Controller\FirstPage\Index'; 13 | parent::setUp(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/etc/adminhtml/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-modifycontent/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-webflow/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-webflow", 3 | "description": "A module to demonstrate navigating between two pages", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0" 13 | }, 14 | "autoload": { 15 | "files": [ "registration.php" ], 16 | "psr-4": { 17 | "Magento\\SampleWebFlow\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-module-interception/etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/etc/events.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample-module-webapi-client/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-webapi-client", 3 | "description": "A module to demonstrate REST API functionality", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/module-catalog": "~100.0" 13 | }, 14 | "autoload": { 15 | "files": [ "registration.php" ], 16 | "psr-4": { 17 | "Magento\\SampleWebapiClient\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-module-webapi-client/etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-servicecontract-new", 3 | "description": "A Magento 2 module that provides a new service contract", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0" 13 | }, 14 | "autoload": { 15 | "files": [ "registration.php" ], 16 | "psr-4": { 17 | "Magento\\SampleServiceContractNew\\": "" 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /sample-external-links/etc/extension_attributes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/etc/frontend/routes.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-modifycontent/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-modifycontent", 3 | "description": "A Magento 2 module that modifies content of a product page", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0", 13 | "magento/module-catalog": "~100.0" 14 | }, 15 | "autoload": { 16 | "files": [ "registration.php" ], 17 | "psr-4": { 18 | "Magento\\SampleModifyContent\\": "" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-service-contract-client", 3 | "description": "A module to demonstrate service contract client", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0", 13 | "magento/module-catalog": "~100.0" 14 | }, 15 | "autoload": { 16 | "files": [ "registration.php" ], 17 | "psr-4": { 18 | "Magento\\SampleServiceContractClient\\": "" 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 0 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-module-theme/Magento_Theme/layout/default.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | images/logo.png 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /module-sample-scss/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/module-sample-scss", 3 | "description": "Demonstrates integration with new scss processor", 4 | "version": "1.0.0-beta", 5 | "require": { 6 | "php": "~5.5.0|~5.6.0|~7.0.0", 7 | "leafo/scssphp": "0.0.12", 8 | "magento/framework": "*", 9 | "magento/magento-composer-installer": "*" 10 | }, 11 | "type": "magento2-module", 12 | "license": [ 13 | "OSL-3.0", 14 | "AFL-3.0" 15 | ], 16 | "autoload": { 17 | "files": [ "registration.php" ], 18 | "psr-4": { 19 | "Magento\\SampleScss\\": "" 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /sample-module-webapi-client/view/frontend/layout/samplewebapiclient_index_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/view/frontend/web/js/model/shipping-rates-validation-rules.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | /*global define*/ 6 | define( 7 | [], 8 | function () { 9 | "use strict"; 10 | return { 11 | getRules: function() { 12 | return { 13 | 'postcode': { 14 | 'required': true 15 | }, 16 | 'country_id': { 17 | 'required': true 18 | } 19 | }; 20 | } 21 | }; 22 | } 23 | ); 24 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/etc/communication.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /sample-module-interception/view/frontend/layout/sampleinterception_index_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | Plugins 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-sample-message-queue", 3 | "description": "A module to demonstrate message queue publisher/consumer functionality", 4 | "type": "magento2-module", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "~100.0.*", 13 | "magento/module-quote": "~100.0.*", 14 | "magento/module-gift-card-account": "~100.0.*", 15 | "magento/module-amqp": "~100.0.*" 16 | }, 17 | "autoload": { 18 | "files": [ "registration.php" ], 19 | "psr-4": { 20 | "Magento\\SampleMessageQueue\\": "" 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/API/Data/FeedSearchResultInterface.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | Brand New Page 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-webflow/view/frontend/layout/webflow_nextpage_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | Next Page 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-interception/Test/Unit/Plugin/PluginAfterTest.php: -------------------------------------------------------------------------------- 1 | getMock('Magento\SampleInterception\Model\Intercepted\ChildAfter'); 15 | $inStr = 'raskolnikov'; 16 | $outStr = "(after) $inStr (/after)"; 17 | $this->assertSame($outStr, $model->afterBaseMethodUppercase($subjectMock, $inStr)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Model/Adminhtml/Source/PaymentAction.php: -------------------------------------------------------------------------------- 1 | AbstractMethod::ACTION_AUTHORIZE, 23 | 'label' => __('Authorize') 24 | ] 25 | ]; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/view/frontend/layout/newpage_index_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | Brand New Page 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-custom-deployment-config/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | Magento\CustomDeploymentConfigExample\Console\Command\ShowCustomDeploymentConfigCommand 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-module-interception/Test/Unit/Plugin/PluginBeforeTest.php: -------------------------------------------------------------------------------- 1 | getMock('Magento\SampleInterception\Model\Intercepted\ChildBefore'); 15 | $inStr = 'gruchenka'; 16 | $output = ["(before) $inStr (/before)"]; 17 | $this->assertSame($output, $model->beforeBaseMethodUppercase($subjectMock, $inStr)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sample-module-webflow/Test/Unit/Block/FirstPageTest.php: -------------------------------------------------------------------------------- 1 | $nextUrl]; 14 | 15 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 16 | $model = $objectManager->getObject('Magento\SampleWebFlow\Block\FirstPage', ['data' => $inputData]); 17 | $this->assertSame($nextUrl, $model->getNextPageUrl()); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Model/SampleFeed.php: -------------------------------------------------------------------------------- 1 | getMock('Magento\SampleInterception\Model\Intercepted\ChildInherit'); 15 | $inStr = 'reverse me'; 16 | $output = "(parent plugin) $inStr (/parent plugin)"; 17 | $this->assertSame($output, $model->afterBaseMethodReverse($subjectMock, $inStr)); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /sample-module-service-contract-replacement/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/view/frontend/layout/sampleservicecontractnew_index_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | Feed List 12 | 13 | 14 | 15 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/view/adminhtml/layout/sampleform_index_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | Sample Form 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/view/frontend/web/js/view/payment/sample_gateway.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | /*browser:true*/ 6 | /*global define*/ 7 | define( 8 | [ 9 | 'uiComponent', 10 | 'Magento_Checkout/js/model/payment/renderer-list' 11 | ], 12 | function ( 13 | Component, 14 | rendererList 15 | ) { 16 | 'use strict'; 17 | rendererList.push( 18 | { 19 | type: 'sample_gateway', 20 | component: 'Magento_SamplePaymentGateway/js/view/payment/method-renderer/sample_gateway' 21 | } 22 | ); 23 | /** Add view logic here if needed */ 24 | return Component.extend({}); 25 | } 26 | ); 27 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-module-form-uicomponent", 3 | "description": "A Magento 2 module that demonstrate Form UI Component with customized field", 4 | "type": "magento2-module", 5 | "version": "1.0.0-beta", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "php": "~5.5.0|~5.6.0|~7.0.0", 12 | "magento/framework": "*", 13 | "magento/module-ui": "*", 14 | "magento/magento-composer-installer": "*" 15 | }, 16 | "extra": { 17 | "map": [ 18 | [ 19 | "*", 20 | "Magento/SampleForm" 21 | ] 22 | ] 23 | }, 24 | "autoload": { 25 | "files": [ 26 | "registration.php" 27 | ], 28 | "psr-4": { 29 | "Magento\\SampleForm\\": "" 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sample-module-webapi-client/view/frontend/web/js/templates/result.html: -------------------------------------------------------------------------------- 1 | 7 | <% if (data.items.length) { %> 8 | 9 | 10 | 11 | <% _.each(data.items[0], function(key, value) { %> 12 | 13 | <% }); %> 14 | 15 | 16 | 17 | <% _.each(data.items, function(item) { %> 18 | 19 | <% _.each(item, function(value) { %> 20 | 21 | <% }); %> 22 | 23 | <% }); %> 24 | 25 |
<%- value %>
<%- value %>
26 | <% } else { %> 27 |

<%- window.jQuery.mage.__('No items found.') %>

28 | <% } %> 29 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/module-sample-payment-gateway", 3 | "description": "Demonstrates integration with payment gateway", 4 | "require": { 5 | "php": "~5.5.0|~5.6.0|~7.0.0", 6 | "magento/module-sales": "100.0.*", 7 | "magento/module-checkout": "100.0.*", 8 | "magento/module-payment": "100.0.*", 9 | "magento/framework": "100.0.*", 10 | "magento/magento-composer-installer": "100.0.*" 11 | }, 12 | "type": "magento2-module", 13 | "version": "100.0.3", 14 | "license": [ 15 | "OSL-3.0", 16 | "AFL-3.0" 17 | ], 18 | "autoload": { 19 | "files": [ "registration.php" ], 20 | "psr-4": { 21 | "Magento\\SamplePaymentGateway\\": "" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/module-sample-shipping-provider", 3 | "description": "Demonstrates creation of in-store pickup shipping provider", 4 | "require": { 5 | "php": "~5.5.0|~5.6.0|~7.0.0", 6 | "magento/module-config": "100.0.*", 7 | "magento/module-store": "100.0.*", 8 | "magento/module-shipping": "100.0.*", 9 | "magento/module-quote": "100.0.*", 10 | "magento/framework": "100.0.*" 11 | }, 12 | "type": "magento2-module", 13 | "version": "100.0.3", 14 | "license": [ 15 | "OSL-3.0", 16 | "AFL-3.0" 17 | ], 18 | "autoload": { 19 | "files": [ "registration.php" ], 20 | "psr-4": { 21 | "Magento\\SampleShippingProvider\\": "" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /sample-bundle-all/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This is a meta package that pulls in all the sample Magento 2 modules from [repo.magento.com](http://repo.magento.com/) 4 | 5 | ## Installation 6 | 7 | To use these samples you will first need to [install Magento 2](http://devdocs.magento.com/guides/v1.0/install-gde/bk-install-guide.html). 8 | 9 | Update the root composer.json for Magento 2 to add a dependency on this package. 10 | 11 | This can be done by adding the following to the 'require' section. 12 | 13 | "magento/sample-bundle-all": "*" 14 | 15 | Ensure you have the repo.magento.com added as a repository in your composer.json and then run `composer update` to have composer download the sample modules. 16 | 17 | Once installed, run the Magento 2 setup application and enable each of the installed modules. 18 | -------------------------------------------------------------------------------- /sample-ee-bundle-all/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This is a meta package that pulls in all the sample Magento 2 EE modules from [repo.magento.com](http://repo.magento.com/) 4 | 5 | ## Installation 6 | 7 | To use these samples you will first need to [install Magento 2 EE](http://devdocs.magento.com/guides/v1.0/install-gde/bk-install-guide.html). 8 | 9 | Update the root composer.json for Magento 2 to add a dependency on this package. 10 | 11 | This can be done by adding the following to the 'require' section. 12 | 13 | "magento/sample-ee-bundle-all": "*" 14 | 15 | Ensure you have the repo.magento.com added as a repository in your composer.json and then run `composer update` to have composer download the sample modules. 16 | 17 | Once installed, run the Magento 2 setup application and enable each of the installed modules. -------------------------------------------------------------------------------- /sample-module-command/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | Magento\CommandExample\Console\Command\GreetingCommand 13 | Magento\CommandExample\Console\Command\CheckActiveModulesCommand 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /sample-module-interception/Plugin/ParentPlugin.php: -------------------------------------------------------------------------------- 1 | urlBuilder = $urlBuilder; 26 | } 27 | 28 | /** 29 | * @param array $queryParams 30 | * @return string 31 | */ 32 | public function getUrl(array $queryParams = []) 33 | { 34 | return $this->urlBuilder->getUrl('sampleservicecontractnew/feed/view', $queryParams); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | main 15 | 16 | Magento\Framework\Logger\Handler\Debug 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Model/Adminhtml/Source/PaymentActionTest.php: -------------------------------------------------------------------------------- 1 | AbstractMethod::ACTION_AUTHORIZE, 21 | 'label' => __('Authorize') 22 | ] 23 | ], 24 | $sourceModel->toOptionArray() 25 | ); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /sample-module-webflow/view/frontend/layout/webflow_firstpage_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | First Page 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /sample-module-modifycontent/view/frontend/layout/catalog_product_view.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | 12 | 13 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /sample-module-interception/Plugin/PluginBefore.php: -------------------------------------------------------------------------------- 1 | logger = $logger; 26 | } 27 | 28 | /** 29 | * Log information about added gift card 30 | * 31 | * @param string $data 32 | */ 33 | public function log($data) 34 | { 35 | $this->logger->debug('ASYNC Handler: Gift Card Added Successfully: ' . $data); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample-module-sample-message-queue/etc/queue.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /sample-module-webflow/Block/FirstPage.php: -------------------------------------------------------------------------------- 1 | getData('url'); 24 | } 25 | } -------------------------------------------------------------------------------- /sample-module-servicecontract-new/API/FeedRepositoryInterface.php: -------------------------------------------------------------------------------- 1 | rssManager = $rssManager; 26 | } 27 | 28 | 29 | /** 30 | * @return FeedInterface[] 31 | */ 32 | public function getFeeds() 33 | { 34 | /** @var FeedInterface[] $feeds */ 35 | $feeds = $this->rssManager->getFeeds(); 36 | return $feeds; 37 | } 38 | 39 | } 40 | -------------------------------------------------------------------------------- /sample-module-interception/Test/Unit/Model/InterceptedTest.php: -------------------------------------------------------------------------------- 1 | model = new \Magento\SampleInterception\Model\Intercepted(); 17 | } 18 | 19 | public function testBaseMethodUppercase() 20 | { 21 | $inStr = 'capitalize me'; 22 | $outStr = 'CAPITALIZE ME'; 23 | $this->assertSame($outStr, $this->model->baseMethodUppercase($inStr)); 24 | } 25 | 26 | public function testBaseMethodReverse() 27 | { 28 | $inStr = 'abcd'; 29 | $outStr = 'dcba'; 30 | $this->assertSame($outStr, $this->model->baseMethodReverse($inStr)); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/view/frontend/templates/feed_list.phtml: -------------------------------------------------------------------------------- 1 | 10 | getFeeds(); 15 | ?> 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
TitleDescriptionLink
getTitle()) ?>getDescription()) ?>getLink() ?>
31 | 32 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/etc/frontend/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | Magento\SamplePaymentGateway\Model\Ui\ConfigProvider 13 | 14 | 15 | 16 | 17 | 18 | 19 | 1 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /sample-module-interception/Test/Unit/Plugin/PluginAroundTest.php: -------------------------------------------------------------------------------- 1 | getMock('Magento\SampleInterception\Model\Intercepted\ChildAround'); 15 | $inStr = 'zosima'; 16 | $outStr = 17 | "(around: after base method) (around: before base method) " 18 | . $inStr 19 | . " (/around: before base method) (/around: after base method)"; 20 | 21 | $proceed = function($in) 22 | { 23 | return $in; 24 | }; 25 | 26 | $this->assertSame($outStr, $model->aroundBaseMethodUppercase($subjectMock, $proceed, $inStr)); 27 | 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Observer/DataAssignObserver.php: -------------------------------------------------------------------------------- 1 | readMethodArgument($observer); 20 | $data = $this->readDataArgument($observer); 21 | 22 | $paymentInfo = $method->getInfoInstance(); 23 | 24 | if ($data->getDataByKey('transaction_result') !== null) { 25 | $paymentInfo->setAdditionalInformation( 26 | 'transaction_result', 27 | $data->getDataByKey('transaction_result') 28 | ); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /module-sample-scss/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | Magento\SampleScss\Preprocessor\Adapter\Scss\Processor 14 | 15 | 16 | scss 17 | Magento\Framework\Css\PreProcessor\Adapter\Less\Processor 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/API/Data/FeedInterface.php: -------------------------------------------------------------------------------- 1 | feed = $objectManager->getObject( 19 | 'Magento\SampleServiceContractNew\Model\SampleFeed', 20 | [] 21 | ); 22 | } 23 | 24 | public function testGetTitle() 25 | { 26 | $this->assertEquals(__('Feed Title'), $this->feed->getTitle()); 27 | } 28 | 29 | public function testGetDescription() 30 | { 31 | $this->assertEquals(__('Feed description'), $this->feed->getDescription()); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /sample-module-webapi-client/view/frontend/templates/web_api_client.phtml: -------------------------------------------------------------------------------- 1 | 8 |
'default/V1/products']) ?>"}}'> 9 |
10 | getTemplateFile('Magento_SampleWebapiClient::filter.phtml')); ?> 11 |

OR

12 | getTemplateFile('Magento_SampleWebapiClient::filter.phtml')); ?> 13 |
14 | 15 |
16 |
17 | 20 |
21 |
22 |
23 |
24 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Model/Ui/ConfigProvider.php: -------------------------------------------------------------------------------- 1 | [ 27 | self::CODE => [ 28 | 'transactionResults' => [ 29 | ClientMock::SUCCESS => __('Success'), 30 | ClientMock::FAILURE => __('Fraud') 31 | ] 32 | ] 33 | ] 34 | ]; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Model/Ui/ConfigProviderTest.php: -------------------------------------------------------------------------------- 1 | [ 20 | ConfigProvider::CODE => [ 21 | 'transactionResults' => [ 22 | ClientMock::SUCCESS => __('Success'), 23 | ClientMock::FAILURE => __('Fraud') 24 | ] 25 | ] 26 | ] 27 | ], 28 | $configProvider->getConfig() 29 | ); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sample-module-service-contract-replacement/Model/QuoteRepository.php: -------------------------------------------------------------------------------- 1 | getIsActive()) { 27 | throw NoSuchEntityException::singleField('cartId', $cartId); 28 | } 29 | return $quote; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Block/Info.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 11 | Sample Service Contract Client 12 | 13 | 14 | 15 | 16 | Sample Service Contract Client 17 | 18 | 19 | 20 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/view/frontend/web/js/model/shipping-rates-validator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | /*global define*/ 6 | define( 7 | [ 8 | 'jquery', 9 | 'mageUtils', 10 | './shipping-rates-validation-rules', 11 | 'mage/translate' 12 | ], 13 | function ($, utils, validationRules, $t) { 14 | "use strict"; 15 | return { 16 | validationErrors: [], 17 | validate: function(address) { 18 | var self = this; 19 | this.validationErrors = []; 20 | $.each(validationRules.getRules(), function(field, rule) { 21 | if (rule.required && utils.isEmpty(address[field])) { 22 | var message = $t('Field ') + field + $t(' is required.'); 23 | self.validationErrors.push(message); 24 | } 25 | }); 26 | return !Boolean(this.validationErrors.length); 27 | } 28 | }; 29 | } 30 | ); 31 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/view/frontend/web/js/view/shipping-rates-validation.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | /*browser:true*/ 6 | /*global define*/ 7 | define( 8 | [ 9 | 'uiComponent', 10 | 'Magento_Checkout/js/model/shipping-rates-validator', 11 | 'Magento_Checkout/js/model/shipping-rates-validation-rules', 12 | '../model/shipping-rates-validator', 13 | '../model/shipping-rates-validation-rules' 14 | ], 15 | function ( 16 | Component, 17 | defaultShippingRatesValidator, 18 | defaultShippingRatesValidationRules, 19 | sampleShippingProviderShippingRatesValidator, 20 | sampleShippingProviderShippingRatesValidationRules 21 | ) { 22 | "use strict"; 23 | defaultShippingRatesValidator.registerValidator('storepickup', sampleShippingProviderShippingRatesValidator); 24 | defaultShippingRatesValidationRules.registerRules('storepickup', sampleShippingProviderShippingRatesValidationRules); 25 | return Component; 26 | } 27 | ); 28 | -------------------------------------------------------------------------------- /sample-module-webapi-client/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This module contains a page which can be viewed at /samplewebapiclient. This page features a demo of REST API being used to query products 4 | 5 | ## Motivation 6 | 7 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent of this sample is to demonstrate how to use REST API. 8 | 9 | ## Technical feature 10 | 11 | A simple page is displayed to collect data from a user and an ajax call is executed to get list of products. Products are filtered with help of SearchCriteria filters set by user. 12 | ![Example](example.png) 13 | 14 | 15 | ## Installation 16 | 17 | This module is intended to be installed using composer. After including this component and enabling it, you can verify it is installed by going the backend at: 18 | 19 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 20 | 21 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 22 | 23 | ## Contributors 24 | 25 | Magento Core team 26 | 27 | ## License 28 | 29 | [Open Source License](LICENSE.txt) 30 | -------------------------------------------------------------------------------- /sample-ee-bundle-all/LICENSE_MIT.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2016 Magento 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /sample-module-sample-message-queue/LICENSE_MIT.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2016 Magento 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /sample-module-servicecontract-new/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 13 | 15 | 16 | 17 | 18 | Magento\SampleServiceContractNew\Model\SampleFeed 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/etc/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 0 15 | 16 | Sample Shipping Provider 17 | 18 | Magento\SampleShippingProvider\Model\Carrier 19 | 20 | This shipping method is currently unavailable. If you would like to ship using this shipping method, please contact us. 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /sample-module-newpage/Test/Unit/IndexTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('Magento\Framework\View\Result\Page') 15 | ->disableOriginalConstructor() 16 | ->getMock(); 17 | $resultFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') 18 | ->disableOriginalConstructor() 19 | ->getMock(); 20 | 21 | // Set up SUT 22 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 23 | $model = $objectManager->getObject('Magento\SampleNewPage\Controller\Index\Index', 24 | ['resultPageFactory' => $resultFactory] 25 | ); 26 | 27 | // Expectations of test 28 | $resultFactory->expects($this->once())->method('create')->willReturn($page); 29 | $this->assertSame($page, $model->execute()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /module-sample-scss/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | An extension to add alternative processor for source files. 4 | This source processor works only with SCSS source files and may used as example. 5 | 6 | ## Motivation 7 | 8 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent of this sample is to demonstrate how to create own processor SCSS source files 9 | 10 | ## Technical feature 11 | 12 | [Magento\SampleScss\Preprocessor\Adapter\Scss\Processor](Preprocessor/Adapter/Scss/Processor.php) Adapter for compilator SCSS source files 13 | [di.xml](etc/di.xml) Override based processor of LESS source files. Set sort order for processors resource files (directive **after**) 14 | 15 | Run **php bin/magento setup:static-content:deploy** command and view files in the folder **pub/static/frontend/Magento/\/en_US/\/css**. 16 | CSS file is generated from test SCSS file. 17 | 18 | ## Installation 19 | 20 | This module is intended to be installed using composer. 21 | 22 | ## Tests 23 | 24 | Unit tests could be found in the [Test/Unit](Test/Unit) directory. 25 | 26 | ## Contributors 27 | 28 | Magento Core team 29 | 30 | ## License 31 | 32 | [Open Source License](LICENSE.txt) 33 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Test/Unit/Controller/Index/IndexTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('Magento\Framework\View\Result\Page') 15 | ->disableOriginalConstructor() 16 | ->getMock(); 17 | $resultFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') 18 | ->disableOriginalConstructor() 19 | ->getMock(); 20 | 21 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 22 | $model = $objectManager->getObject('Magento\SampleServiceContractNew\Controller\Index\Index', 23 | ['resultPageFactory' => $resultFactory] 24 | ); 25 | 26 | // Expectations of test 27 | $resultFactory->expects($this->once())->method('create')->willReturn($page); 28 | $this->assertSame($page, $model->execute()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /sample-module-interception/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /sample-module-interception/Test/Unit/Controller/Index/IndexTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('Magento\Framework\View\Result\Page') 15 | ->disableOriginalConstructor() 16 | ->getMock(); 17 | $resultFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') 18 | ->disableOriginalConstructor() 19 | ->getMock(); 20 | 21 | // Set up SUT 22 | $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 23 | $model = $objectManager->getObject('Magento\SampleInterception\Controller\Index\Index', 24 | ['resultPageFactory' => $resultFactory] 25 | ); 26 | 27 | // Expectations of test 28 | $resultFactory->expects($this->once())->method('create')->willReturn($page); 29 | $this->assertSame($page, $model->execute()); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /sample-bundle-all/composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magento/sample-bundle-all", 3 | "description": "A package that pulls in all Magento 2 sample modules", 4 | "type": "metapackage", 5 | "version": "1.0.0", 6 | "license": [ 7 | "OSL-3.0", 8 | "AFL-3.0" 9 | ], 10 | "require": { 11 | "magento/sample-module-minimal": "~1.0", 12 | "magento/sample-module-theme": "~1.0", 13 | "magento/sample-module-newpage": "~1.0", 14 | "magento/sample-module-webflow": "~1.0", 15 | "magento/sample-module-modifycontent": "~1.0", 16 | "magento/sample-module-interception": "~1.0", 17 | "magento/sample-module-service-contract-client": "~1.0", 18 | "magento/sample-module-webapi-client": "~1.0", 19 | "magento/sample-module-service-contract-replacement": "~1.0", 20 | "magento/sample-module-servicecontract-new": "~1.0", 21 | "magento/sample-module-command": "~1.0", 22 | "magento/sample-module-custom-deployment-config": "~1.0", 23 | "magento/module-sample-scss": "~1.0", 24 | "magento/sample-module-form-uicomponent": "~1.0", 25 | "magento/module-sample-payment-gateway": "~1.0", 26 | "magento/sample-module-shipping-provider": "~1.0" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /sample-module-newpage/Controller/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 25 | parent::__construct($context); 26 | } 27 | /** 28 | * Load the page defined in view/frontend/layout/samplenewpage_index_index.xml 29 | * 30 | * @return \Magento\Framework\View\Result\Page 31 | */ 32 | public function execute() 33 | { 34 | return $this->resultPageFactory->create(); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sample-module-minimal/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This most basic skeleton module for Magento 2. 4 | 5 | ## Motivation 6 | 7 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent is to learn by example, following our best practices for developing a modular site using Magento 2. 8 | 9 | ## Technical feature 10 | 11 | This component demonstrates the modularity of Magento 2. The [module.xml](etc/module.xml) is read by the system and used to manage isolated modules of the system. By enabling this module, you can see how the system becomes aware of a module and loads the features packaged within a module. 12 | 13 | ## Installation 14 | 15 | This module is intended to be installed using composer. After including this component and enabling it, you can verify it is installed by going the backend at: 16 | 17 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 18 | 19 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 20 | 21 | ## Tests 22 | 23 | Any tests would typically be found in the [Test](Test) directory. Since this module has no code, no tests are provided. 24 | 25 | ## Contributors 26 | 27 | Magento Core team 28 | 29 | ## License 30 | 31 | [Open Source License](LICENSE.txt) 32 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This module contains a page which can be viewed at /servicecontractclient. 4 | The page provides a result of usage service contracts of products module. 5 | 6 | ## Motivation 7 | 8 | This is one of a collection of examples to demonstrate the features of Magento 2. 9 | The intent of this sample is to demonstrate how to use service contracts. 10 | 11 | ## Technical feature 12 | 13 | [Block\ProductsList](Block/ProductList.php) demonstrates usage of service contracts of Magento 2. 14 | 15 | It uses API of Catalog to get list of products and list of product types. 16 | Also it uses API from Framework to set filters in product list. 17 | 18 | ## Installation 19 | 20 | This module is intended to be installed using composer. 21 | After including this component and enabling it, you can verify it is installed by going the backend at: 22 | 23 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 24 | 25 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 26 | 27 | ## Tests 28 | 29 | Unit tests could be found in the [Test/Unit](Test/Unit) directory. 30 | 31 | ## Contributors 32 | 33 | Magento Core team 34 | 35 | ## License 36 | 37 | [Open Source License](LICENSE.txt) 38 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Model/FeedTransformer.php: -------------------------------------------------------------------------------- 1 | zendFeed = $zendFeed; 25 | } 26 | 27 | /** 28 | * Get xml from feed data 29 | * 30 | * @codeCoverageIgnore due to static method call (\Zend_Feed::importArray) 31 | * 32 | * @param FeedInterface $feed 33 | * @return string 34 | */ 35 | public function toXml(FeedInterface $feed) 36 | { 37 | $data = [ 38 | 'title' => $feed->getTitle(), 39 | 'link' => $feed->getLink(), 40 | 'charset' => 'UTF-8', 41 | 'description' => $feed->getDescription(), 42 | ]; 43 | $rssFeedFromArray = $this->zendFeed->importArray($data, 'rss'); 44 | $xml = $rssFeedFromArray->saveXML(); 45 | return $xml; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/Controller/Adminhtml/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 25 | parent::__construct($context); 26 | } 27 | 28 | /** 29 | * Load the page defined in view/frontend/layout/samplenewpage_index_index.xml 30 | * 31 | * @return \Magento\Framework\View\Result\Page 32 | */ 33 | public function execute() 34 | { 35 | return $this->resultPageFactory->create(); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /sample-module-service-contract-replacement/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | An extension to replace GiftMessage service contracts of Magento 2 4 | 5 | ## Motivation 6 | 7 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent of this sample is to demonstrate how to replace service contracts of Magento 2. 8 | 9 | ## Technical feature 10 | 11 | Model\CartRepository and Model\ItemRepository implement service contracts of Magento 2. 12 | 13 | Model\CartRepository implements CartRepositoryInterface of GiftMessage module. 14 | Model\ItemRepository implements ItemRepositoryInterface of GiftMessage module. 15 | Those models uses cache storage to save gift messages for order or order item 16 | 17 | ## Installation 18 | 19 | This module is intended to be installed using composer. After including this component and enabling it, you can verify it is installed by going the backend at: 20 | 21 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 22 | 23 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 24 | 25 | ## Tests 26 | 27 | Unit tests could be found in the [Test/Unit](Test/Unit) directory. 28 | 29 | ## Contributors 30 | 31 | Magento Core team 32 | 33 | ## License 34 | 35 | [Open Source License](LICENSE.txt) 36 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Model/Data/Feed.php: -------------------------------------------------------------------------------- 1 | _get(self::KEY_ID); 21 | } 22 | 23 | /** 24 | * @return string 25 | */ 26 | public function getTitle() 27 | { 28 | return $this->_get(self::KEY_TITLE); 29 | } 30 | 31 | /** 32 | * @return string 33 | */ 34 | public function getDescription() 35 | { 36 | return $this->_get(self::KEY_DESCRIPTION); 37 | } 38 | 39 | /** 40 | * @return string 41 | */ 42 | public function getLink() 43 | { 44 | return $this->_get(self::KEY_LINK); 45 | } 46 | 47 | /** 48 | * @param string $value 49 | * @return $this 50 | */ 51 | public function setLink($value) 52 | { 53 | $this->setData(self::KEY_LINK, $value); 54 | return $this; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /sample-module-command/Test/Unit/Console/Command/CheckActiveModulesCommandTest.php: -------------------------------------------------------------------------------- 1 | moduleList = $this->getMockForAbstractClass('Magento\Framework\Module\ModuleListInterface'); 27 | $this->command = new CheckActiveModulesCommand($this->moduleList); 28 | } 29 | 30 | public function testExecute() 31 | { 32 | $this->moduleList->expects($this->once())->method('getNames')->willReturn([]); 33 | $commandTester = new CommandTester($this->command); 34 | $commandTester->execute([]); 35 | 36 | $this->assertContains('List of active modules', $commandTester->getDisplay()); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Response/TxnIdHandler.php: -------------------------------------------------------------------------------- 1 | getPayment(); 34 | 35 | /** @var $payment \Magento\Sales\Model\Order\Payment */ 36 | $payment->setTransactionId($response[self::TXN_ID]); 37 | $payment->setIsTransactionClosed(false); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/Controller/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 33 | } 34 | 35 | /** 36 | * @return \Magento\Framework\View\Result\Page 37 | */ 38 | public function execute() 39 | { 40 | return $this->resultPageFactory->create(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sample-module-webapi-client/Controller/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 36 | } 37 | 38 | /** 39 | * Index action 40 | * 41 | * @return Page 42 | */ 43 | public function execute() 44 | { 45 | return $this->resultPageFactory->create(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /sample-module-interception/Controller/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 31 | parent::__construct($context); 32 | } 33 | 34 | /** 35 | * Loads page content 36 | * 37 | * @return \Magento\Framework\View\Result\Page 38 | */ 39 | public function execute() 40 | { 41 | return $this->resultPageFactory->create(); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/Test/Unit/Block/System/Config/Form/Field/LocationsTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder('Magento\Backend\Block\Template\Context') 27 | ->disableOriginalConstructor() 28 | ->getMock(); 29 | 30 | $this->block = new Locations($context); 31 | } 32 | 33 | public function testGetColumns() 34 | { 35 | $this->assertArrayHasKey('title', $this->block->getColumns()); 36 | $this->assertArrayHasKey('street', $this->block->getColumns()); 37 | $this->assertArrayHasKey('phone', $this->block->getColumns()); 38 | $this->assertArrayHasKey('message', $this->block->getColumns()); 39 | $this->assertCount(4, $this->block->getColumns()); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sample-external-links/etc/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 10 | 12 | 14 | 15 | 17 | 18 | 19 | 20 | 21 | 22 | product_external_links 23 | link_id 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /sample-module-webflow/Controller/NextPage/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 30 | parent::__construct($context); 31 | } 32 | 33 | /** 34 | * Loads page content 35 | * 36 | * @return \Magento\Framework\View\Result\Page 37 | */ 38 | public function execute() 39 | { 40 | return $this->resultPageFactory->create(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sample-module-webflow/Controller/FirstPage/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 30 | parent::__construct($context); 31 | } 32 | 33 | /** 34 | * Loads page content 35 | * 36 | * @return \Magento\Framework\View\Result\Page 37 | */ 38 | public function execute() 39 | { 40 | return $this->resultPageFactory->create(); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Test/Unit/Model/UrlBuilderTest.php: -------------------------------------------------------------------------------- 1 | urlBuilder = $this->getMockBuilder('Magento\Framework\UrlInterface') 22 | ->getMockForAbstractClass(); 23 | $this->target = $objectManager->getObject('Magento\SampleServiceContractNew\Model\UrlBuilder', 24 | ['urlBuilder' => $this->urlBuilder] 25 | ); 26 | } 27 | 28 | public function testGetUrl() 29 | { 30 | $queryParams = ['queryParamsArray']; 31 | $url = 'sampleUrl'; 32 | $this->urlBuilder->expects($this->once()) 33 | ->method('getUrl') 34 | ->with('sampleservicecontractnew/feed/view', $queryParams) 35 | ->willReturn($url); 36 | $this->assertEquals($url, $this->target->getUrl($queryParams)); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Controller/Index/Index.php: -------------------------------------------------------------------------------- 1 | resultPageFactory = $resultPageFactory; 33 | parent::__construct($context); 34 | } 35 | /** 36 | * Load the page defined in view/frontend/layout/SampleServiceContractNew_index_index.xml 37 | * 38 | * @return Page 39 | */ 40 | public function execute() 41 | { 42 | return $this->resultPageFactory->create(); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Request/MockDataRequest.php: -------------------------------------------------------------------------------- 1 | getPayment(); 33 | 34 | $transactionResult = $payment->getAdditionalInformation('transaction_result'); 35 | return [ 36 | self::FORCE_RESULT => $transactionResult === null 37 | ? ClientMock::SUCCESS 38 | : $transactionResult 39 | ]; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Response/TxnIdHandlerTest.php: -------------------------------------------------------------------------------- 1 | ['fcd7f001e9274fdefb14bff91c799306'] 18 | ]; 19 | 20 | $paymentDO = $this->getMock(PaymentDataObjectInterface::class); 21 | $paymentModel = $this->getMockBuilder(Payment::class) 22 | ->disableOriginalConstructor() 23 | ->getMock(); 24 | 25 | $paymentDO->expects(static::once()) 26 | ->method('getPayment') 27 | ->willReturn($paymentModel); 28 | 29 | 30 | $paymentModel->expects(static::once()) 31 | ->method('setTransactionId') 32 | ->with($response[TxnIdHandler::TXN_ID]); 33 | $paymentModel->expects(static::once()) 34 | ->method('setIsTransactionClosed') 35 | ->with(false); 36 | 37 | $request = new TxnIdHandler(); 38 | $request->handle(['payment' => $paymentDO], $response); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /sample-module-interception/Model/Intercepted.php: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 1 13 | 0 14 | SamplePaymentGatewayFacade 15 | 16 | pending_payment 17 | authorize 18 | Payment method (SampleGateway) 19 | USD 20 | 1 21 | 1 22 | 1 23 | 1 24 | 1 25 | 1 26 | MERCHANT_KEY 27 | FRAUD_MSG_LIST 28 | FRAUD_MSG_LIST 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /sample-module-interception/Plugin/PluginAround.php: -------------------------------------------------------------------------------- 1 | getMock('Magento\SampleInterception\Model\Intercepted\ChildBefore'); 16 | $after = $this->getMock('Magento\SampleInterception\Model\Intercepted\ChildAfter'); 17 | $around = $this->getMock('Magento\SampleInterception\Model\Intercepted\ChildAround'); 18 | $inherit = $this->getMock('Magento\SampleInterception\Model\Intercepted\ChildInherit'); 19 | 20 | 21 | /** @var \Magento\SampleInterception\Block\Page $model */ 22 | $model = $objectManager->getObject( 23 | 'Magento\SampleInterception\Block\Page', 24 | [ 25 | 'beforeModel' => $before, 26 | 'afterModel' => $after, 27 | 'aroundModel' => $around, 28 | 'inheritModel' => $inherit 29 | ] 30 | ); 31 | $this->assertSame($before, $model->getModelBefore()); 32 | $this->assertSame($after, $model->getModelAfter()); 33 | $this->assertSame($around, $model->getModelAround()); 34 | $this->assertSame($inherit, $model->getModelInherit()); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Http/TransferFactory.php: -------------------------------------------------------------------------------- 1 | transferBuilder = $transferBuilder; 27 | } 28 | 29 | /** 30 | * Builds gateway transfer object 31 | * 32 | * @param array $request 33 | * @return TransferInterface 34 | */ 35 | public function create(array $request) 36 | { 37 | return $this->transferBuilder 38 | ->setBody($request) 39 | ->setMethod('POST') 40 | ->setHeaders( 41 | [ 42 | 'force_result' => isset($request[MockDataRequest::FORCE_RESULT]) 43 | ? $request[MockDataRequest::FORCE_RESULT] 44 | : null 45 | ] 46 | ) 47 | ->build(); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/view/frontend/layout/checkout_cart_index.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | Magento_SampleShippingProvider/js/view/shipping-rates-validation 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /sample-module-command/Console/Command/CheckActiveModulesCommand.php: -------------------------------------------------------------------------------- 1 | moduleList = $moduleList; 29 | parent::__construct(); 30 | } 31 | 32 | /** 33 | * {@inheritdoc} 34 | */ 35 | protected function configure() 36 | { 37 | $this->setName('example:modules:check-active') 38 | ->setDescription('Checks application status (installed or not)'); 39 | 40 | parent::configure(); 41 | } 42 | 43 | /** 44 | * {@inheritdoc} 45 | */ 46 | protected function execute(InputInterface $input, OutputInterface $output) 47 | { 48 | $output->writeln('List of active modules:'); 49 | foreach ($this->moduleList->getNames() as $moduleName) { 50 | $output->writeln('' . $moduleName . ''); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Block/FeedList.php: -------------------------------------------------------------------------------- 1 | feedRepository = $feedRepository; 39 | $this->searchCriteriaBuilder = $searchCriteriaBuilder; 40 | } 41 | 42 | /** 43 | * @return \Magento\SampleServiceContractNew\API\Data\FeedInterface[] 44 | */ 45 | public function getFeeds() 46 | { 47 | $searchCriteria = $this->searchCriteriaBuilder->create(); 48 | $searchResult = $this->feedRepository->getList($searchCriteria); 49 | return $searchResult->getItems(); 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/view/frontend/web/js/view/payment/method-renderer/sample_gateway.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | /*browser:true*/ 6 | /*global define*/ 7 | define( 8 | [ 9 | 'Magento_Checkout/js/view/payment/default' 10 | ], 11 | function (Component) { 12 | 'use strict'; 13 | 14 | return Component.extend({ 15 | defaults: { 16 | template: 'Magento_SamplePaymentGateway/payment/form', 17 | transactionResult: '' 18 | }, 19 | 20 | initObservable: function () { 21 | 22 | this._super() 23 | .observe([ 24 | 'transactionResult' 25 | ]); 26 | return this; 27 | }, 28 | 29 | getCode: function() { 30 | return 'sample_gateway'; 31 | }, 32 | 33 | getData: function() { 34 | return { 35 | 'method': this.item.method, 36 | 'additional_data': { 37 | 'transaction_result': this.transactionResult() 38 | } 39 | }; 40 | }, 41 | 42 | getTransactionResults: function() { 43 | return _.map(window.checkoutConfig.payment.sample_gateway.transactionResults, function(value, key) { 44 | return { 45 | 'value': key, 46 | 'transaction_result': value 47 | } 48 | }); 49 | } 50 | }); 51 | } 52 | ); -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Response/FraudHandler.php: -------------------------------------------------------------------------------- 1 | getPayment(); 38 | 39 | $payment->setAdditionalInformation( 40 | self::FRAUD_MSG_LIST, 41 | (array)$response[self::FRAUD_MSG_LIST] 42 | ); 43 | 44 | /** @var $payment Payment */ 45 | $payment->setIsTransactionPending(true); 46 | $payment->setIsFraudDetected(true); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /sample-module-command/Test/Unit/Console/Command/GreetingCommandTest.php: -------------------------------------------------------------------------------- 1 | command = new GreetingCommand(); 22 | } 23 | 24 | public function testExecuteAnonymous() 25 | { 26 | $commandTester = new CommandTester($this->command); 27 | $commandTester->execute( 28 | [ 29 | '-a' => true 30 | ] 31 | ); 32 | 33 | $this->assertContains('Hello Anonymous!', $commandTester->getDisplay()); 34 | } 35 | 36 | public function testExecuteName() 37 | { 38 | $commandTester = new CommandTester($this->command); 39 | $commandTester->execute( 40 | [ 41 | GreetingCommand::NAME_ARGUMENT => 'Test' 42 | ] 43 | ); 44 | 45 | $this->assertContains('Hello Test!', $commandTester->getDisplay()); 46 | } 47 | 48 | /** 49 | * @expectedException \InvalidArgumentException 50 | * @expectedExceptionMessage Argument name is missing 51 | */ 52 | public function testExecuteError() 53 | { 54 | $commandTester = new CommandTester($this->command); 55 | $commandTester->execute([]); 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | An extension to add Shipping carrier. This extension add "In-Store Pickup" shipping carrier. 4 | Several pickup locations can be configured with this shipping carrier. 5 | 6 | ## Motivation 7 | 8 | This is one of a collection of examples to demonstrate the features of Magento 2. The intent of this sample is to demonstrate how to create own Shipping extension. 9 | 10 | ## Technical feature 11 | 12 | [Carrier class](Model/Carrier.php) implements CarrierInterface and represents a shipping carrier. Shipping carrier should have one or more shipping methods. 13 | Shipping method should have carrier code, carrier title, method code, method title and price. Shipping method represented by \Magento\Quote\Model\Quote\Address\RateResult\Method class. 14 | [Carrier class](Model/Carrier.php) has 'collectRates' method used to get applicable shipping methods. 15 | [Configuration](etc/config.xml) 'registers' [Carrier class](Model/Carrier.php) as a shipping carrier. 16 | [system.xml](etc/adminhtml/system.xml) makes our module configurable in the admin panel. 17 | 18 | ## Installation 19 | 20 | This module is intended to be installed using composer. After including this component and enabling it, you can verify it is installed by going the backend at: 21 | 22 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 23 | 24 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 25 | 26 | ## Tests 27 | 28 | Unit tests could be found in the [Test/Unit](Test/Unit) directory. 29 | 30 | ## Contributors 31 | 32 | Magento Core team 33 | 34 | ## License 35 | 36 | [Open Source License](LICENSE.txt) 37 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Validator/ResponseCodeValidator.php: -------------------------------------------------------------------------------- 1 | isSuccessfulTransaction($response)) { 31 | return $this->createResult( 32 | true, 33 | [] 34 | ); 35 | } else { 36 | return $this->createResult( 37 | false, 38 | [__('Gateway rejected the transaction.')] 39 | ); 40 | } 41 | } 42 | 43 | /** 44 | * @param array $response 45 | * @return bool 46 | */ 47 | private function isSuccessfulTransaction(array $response) 48 | { 49 | return isset($response[self::RESULT_CODE]) 50 | && $response[self::RESULT_CODE] !== ClientMock::FAILURE; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Response/FraudHandlerTest.php: -------------------------------------------------------------------------------- 1 | [ 18 | 'Something happened.' 19 | ] 20 | ]; 21 | 22 | $paymentDO = $this->getMock(PaymentDataObjectInterface::class); 23 | $paymentModel = $this->getMockBuilder(Payment::class) 24 | ->disableOriginalConstructor() 25 | ->getMock(); 26 | 27 | $paymentDO->expects(static::once()) 28 | ->method('getPayment') 29 | ->willReturn($paymentModel); 30 | 31 | $paymentModel->expects(static::once()) 32 | ->method('setAdditionalInformation') 33 | ->with( 34 | FraudHandler::FRAUD_MSG_LIST, 35 | $response[FraudHandler::FRAUD_MSG_LIST] 36 | ); 37 | 38 | $paymentModel->expects(static::once()) 39 | ->method('setIsTransactionPending') 40 | ->with(true); 41 | $paymentModel->expects(static::once()) 42 | ->method('setIsFraudDetected') 43 | ->with(true); 44 | 45 | $request = new FraudHandler(); 46 | $request->handle(['payment' => $paymentDO], $response); 47 | 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Controller/Feed/View.php: -------------------------------------------------------------------------------- 1 | feedRepository = $feedRepository; 39 | $this->feedTransformer = $feedTransformer; 40 | } 41 | 42 | /** 43 | * @return void 44 | */ 45 | public function execute() 46 | { 47 | $feedId = $this->getRequest()->getParam('type'); 48 | 49 | /** @var FeedInterface $feed */ 50 | $feed = $this->feedRepository->getById($feedId); 51 | 52 | $this->getResponse()->setHeader('Content-type', 'text/xml; charset=UTF-8'); 53 | $this->getResponse()->setBody($this->feedTransformer->toXml($feed)); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /sample-module-shipping-provider/Block/System/Config/Form/Field/Locations.php: -------------------------------------------------------------------------------- 1 | addColumn( 25 | 'title', 26 | [ 27 | 'label' => __('Title'), 28 | 'class' => 'validate-no-empty validate-alphanum-with-spaces' 29 | ] 30 | ); 31 | $this->addColumn( 32 | 'street', 33 | [ 34 | 'label' => __('Street Address'), 35 | 'class' => 'validate-no-empty validate-alphanum-with-spaces' 36 | ] 37 | ); 38 | $this->addColumn( 39 | 'phone', 40 | [ 41 | 'label' => __('Phone Number'), 42 | 'class' => 'validate-no-empty validate-no-empty validate-phoneStrict' 43 | ] 44 | ); 45 | $this->addColumn( 46 | 'message', 47 | [ 48 | 'label' => __('Message'), 49 | 'class' => 'validate-no-empty' 50 | ] 51 | ); 52 | $this->_addAfter = false; 53 | parent::_construct(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Model/Feed.php: -------------------------------------------------------------------------------- 1 | _get(self::KEY_ID); 34 | } 35 | 36 | /** 37 | * @return string 38 | */ 39 | public function getTitle() 40 | { 41 | return $this->title; 42 | } 43 | 44 | /** 45 | * @param string $title 46 | */ 47 | public function setTitle($title) 48 | { 49 | $this->title = $title; 50 | } 51 | 52 | /** 53 | * @return string 54 | */ 55 | public function getDescription() 56 | { 57 | return $this->description; 58 | } 59 | 60 | /** 61 | * @param string $description 62 | */ 63 | public function setDescription($description) 64 | { 65 | $this->description = $description; 66 | } 67 | 68 | /** 69 | * @return string 70 | */ 71 | public function getLink() 72 | { 73 | return $this->link; 74 | } 75 | 76 | /** 77 | * @param string $link 78 | */ 79 | public function setLink($link) 80 | { 81 | $this->link = $link; 82 | } 83 | 84 | } 85 | -------------------------------------------------------------------------------- /sample-external-links/Model/ExternalLinks/Provider.php: -------------------------------------------------------------------------------- 1 | entityManager = $entityManager; 40 | $this->loader = $loader; 41 | $this->externalLinkFactory = $externalLinkFactory; 42 | } 43 | 44 | /** 45 | * @inheritdoc 46 | */ 47 | public function getLinks($productId) 48 | { 49 | $externalLinks = []; 50 | $ids = $this->loader->getIdsByProductId($productId); 51 | 52 | foreach($ids as $id) { 53 | $externalLink = $this->externalLinkFactory->create(); 54 | $externalLinks[] = $this->entityManager->load($externalLink, $id); 55 | } 56 | 57 | return $externalLinks; 58 | } 59 | } -------------------------------------------------------------------------------- /sample-external-links/Model/ResourceModel/ExternalLinks/Loader.php: -------------------------------------------------------------------------------- 1 | metadataPool = $metadataPool; 35 | $this->resourceConnection = $resourceConnection; 36 | } 37 | 38 | /** 39 | * @param $productId 40 | * @return array 41 | * @throws \Exception 42 | */ 43 | public function getIdsByProductId($productId) 44 | { 45 | $metadata = $this->metadataPool->getMetadata(ExternalLinkInterface::class); 46 | $connection = $this->resourceConnection->getConnection(); 47 | 48 | $select = $connection 49 | ->select() 50 | ->from($metadata->getEntityTable(), ExternalLinkInterface::LINK_ID) 51 | ->where(ExternalLinkInterface::PRODUCT_ID . ' = ?', $productId); 52 | $ids = $connection->fetchCol($select); 53 | 54 | return $ids ?: []; 55 | } 56 | } -------------------------------------------------------------------------------- /module-sample-scss/Preprocessor/Adapter/Scss/Processor.php: -------------------------------------------------------------------------------- 1 | assetSource = $assetSource; 38 | $this->logger = $logger; 39 | } 40 | 41 | /** 42 | * Process file content 43 | * 44 | * @param File $asset 45 | * @return string 46 | */ 47 | public function processContent(File $asset) 48 | { 49 | $path = $asset->getPath(); 50 | try { 51 | $compiler = new \scssc(); 52 | $content = $this->assetSource->getContent($asset); 53 | 54 | if (trim($content) === '') { 55 | return ''; 56 | } 57 | 58 | return $compiler->compile($content); 59 | } catch (\Exception $e) { 60 | $errorMessage = PHP_EOL . self::ERROR_MESSAGE_PREFIX . PHP_EOL . $path . PHP_EOL . $e->getMessage(); 61 | $this->logger->critical($errorMessage); 62 | 63 | return $errorMessage; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /sample-module-servicecontract-new/Test/Unit/Model/Data/FeedTest.php: -------------------------------------------------------------------------------- 1 | feed = $objectManager->getObject( 21 | 'Magento\SampleServiceContractNew\Model\Data\Feed', 22 | [ 23 | 'data' => [ 24 | FeedInterface::KEY_ID => 'feedId', 25 | FeedInterface::KEY_TITLE => 'feedTitle', 26 | FeedInterface::KEY_DESCRIPTION => 'feedDescription', 27 | FeedInterface::KEY_LINK => 'feedLink', 28 | ] 29 | ] 30 | ); 31 | } 32 | 33 | public function testGetId() 34 | { 35 | $this->assertEquals('feedId', $this->feed->getId()); 36 | } 37 | 38 | public function testGetTitle() 39 | { 40 | $this->assertEquals('feedTitle', $this->feed->getTitle()); 41 | } 42 | 43 | public function testGetDescription() 44 | { 45 | $this->assertEquals('feedDescription', $this->feed->getDescription()); 46 | } 47 | 48 | public function testGetLink() 49 | { 50 | $this->assertEquals('feedLink', $this->feed->getLink()); 51 | } 52 | 53 | public function testSetLink() 54 | { 55 | $this->feed->setLink('feedTestLink'); 56 | $this->assertEquals('feedTestLink', $this->feed->getLink()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Request/AuthorizationRequest.php: -------------------------------------------------------------------------------- 1 | config = $config; 26 | } 27 | 28 | /** 29 | * Builds ENV request 30 | * 31 | * @param array $buildSubject 32 | * @return array 33 | */ 34 | public function build(array $buildSubject) 35 | { 36 | if (!isset($buildSubject['payment']) 37 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface 38 | ) { 39 | throw new \InvalidArgumentException('Payment data object should be provided'); 40 | } 41 | 42 | /** @var PaymentDataObjectInterface $payment */ 43 | $payment = $buildSubject['payment']; 44 | $order = $payment->getOrder(); 45 | $address = $order->getShippingAddress(); 46 | 47 | return [ 48 | 'TXN_TYPE' => 'A', 49 | 'INVOICE' => $order->getOrderIncrementId(), 50 | 'AMOUNT' => $order->getGrandTotalAmount(), 51 | 'CURRENCY' => $order->getCurrencyCode(), 52 | 'EMAIL' => $address->getEmail(), 53 | 'MERCHANT_KEY' => $this->config->getValue( 54 | 'merchant_gateway_key', 55 | $order->getStoreId() 56 | ) 57 | ]; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Http/TransferFactoryTest.php: -------------------------------------------------------------------------------- 1 | 'value', 19 | MockDataRequest::FORCE_RESULT => 1 20 | ]; 21 | 22 | $transferBuilder = $this->getMockBuilder(TransferBuilder::class) 23 | ->disableOriginalConstructor() 24 | ->getMock(); 25 | $transferObject = $this->getMock(TransferInterface::class); 26 | 27 | $transferBuilder->expects(static::once()) 28 | ->method('setBody') 29 | ->with($request) 30 | ->willReturnSelf(); 31 | $transferBuilder->expects(static::once()) 32 | ->method('setMethod') 33 | ->with('POST') 34 | ->willReturnSelf(); 35 | $transferBuilder->expects(static::once()) 36 | ->method('setHeaders') 37 | ->with( 38 | [ 39 | 'force_result' => 1 40 | ] 41 | ) 42 | ->willReturnSelf(); 43 | 44 | $transferBuilder->expects(static::once()) 45 | ->method('build') 46 | ->willReturn($transferObject); 47 | 48 | $transferFactory = new TransferFactory($transferBuilder); 49 | 50 | static::assertSame( 51 | $transferObject, 52 | $transferFactory->create($request) 53 | ); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Request/VoidRequest.php: -------------------------------------------------------------------------------- 1 | config = $config; 27 | } 28 | 29 | /** 30 | * Builds ENV request 31 | * 32 | * @param array $buildSubject 33 | * @return array 34 | */ 35 | public function build(array $buildSubject) 36 | { 37 | if (!isset($buildSubject['payment']) 38 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface 39 | ) { 40 | throw new \InvalidArgumentException('Payment data object should be provided'); 41 | } 42 | 43 | /** @var PaymentDataObjectInterface $paymentDO */ 44 | $paymentDO = $buildSubject['payment']; 45 | 46 | $order = $paymentDO->getOrder(); 47 | $payment = $paymentDO->getPayment(); 48 | 49 | if (!$payment instanceof OrderPaymentInterface) { 50 | throw new \LogicException('Order payment should be provided.'); 51 | } 52 | 53 | return [ 54 | 'TXN_TYPE' => 'V', 55 | 'TXN_ID' => $payment->getLastTransId(), 56 | 'MERCHANT_KEY' => $this->config->getValue( 57 | 'merchant_gateway_key', 58 | $order->getStoreId() 59 | ) 60 | ]; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Gateway/Request/CaptureRequest.php: -------------------------------------------------------------------------------- 1 | config = $config; 27 | } 28 | 29 | /** 30 | * Builds ENV request 31 | * 32 | * @param array $buildSubject 33 | * @return array 34 | */ 35 | public function build(array $buildSubject) 36 | { 37 | if (!isset($buildSubject['payment']) 38 | || !$buildSubject['payment'] instanceof PaymentDataObjectInterface 39 | ) { 40 | throw new \InvalidArgumentException('Payment data object should be provided'); 41 | } 42 | 43 | /** @var PaymentDataObjectInterface $paymentDO */ 44 | $paymentDO = $buildSubject['payment']; 45 | 46 | $order = $paymentDO->getOrder(); 47 | 48 | $payment = $paymentDO->getPayment(); 49 | 50 | if (!$payment instanceof OrderPaymentInterface) { 51 | throw new \LogicException('Order payment should be provided.'); 52 | } 53 | 54 | return [ 55 | 'TXN_TYPE' => 'S', 56 | 'TXN_ID' => $payment->getLastTransId(), 57 | 'MERCHANT_KEY' => $this->config->getValue( 58 | 'merchant_gateway_key', 59 | $order->getStoreId() 60 | ) 61 | ]; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /sample-module-form-uicomponent/view/adminhtml/web/js/form/element/color-select.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright © 2016 Magento. All rights reserved. 3 | * See COPYING.txt for license details. 4 | */ 5 | 6 | define(['Magento_Ui/js/form/element/abstract'],function(Abstract) { 7 | return Abstract.extend({ 8 | defaults: { 9 | items: [ 10 | { 11 | name: 'yellow', 12 | val: '#ec971f' 13 | }, 14 | { 15 | name:'green', 16 | val:'#5cb85c' 17 | }, 18 | { 19 | name:'blue', 20 | val:'#28a4c9' 21 | }, 22 | { 23 | name:'red', 24 | val:'#e9322d' 25 | } 26 | ] 27 | }, 28 | 29 | /** 30 | * Initializes component, invokes initialize method of Abstract class. 31 | * 32 | * @returns {Object} Chainable. 33 | */ 34 | initialize: function () { 35 | return this._super(); 36 | }, 37 | 38 | 39 | /** 40 | * Init observables 41 | * 42 | * @returns {Object} Chainable. 43 | */ 44 | initObservable: function () { 45 | return this._super() 46 | .observe([ 47 | 'items' 48 | ]); 49 | }, 50 | 51 | /** 52 | * Change currently selected color 53 | * 54 | * @param {String} color 55 | */ 56 | selectColor: function(color){ 57 | this.value(color); 58 | }, 59 | 60 | /** 61 | * Returns class based on current selected color 62 | * 63 | * @param {String} color 64 | * @returns {String} 65 | */ 66 | isSelected: function (color) { 67 | return color === this.value() ? 'selected' : ''; 68 | } 69 | }); 70 | }); 71 | -------------------------------------------------------------------------------- /sample-module-custom-deployment-config/Test/Unit/Console/Command/ShowCustomDeploymentConfigCommandTest.php: -------------------------------------------------------------------------------- 1 | deploymentConfigMock = $this->getMock('Magento\Framework\App\DeploymentConfig', [], [], '', false); 27 | $command = new ShowCustomDeploymentConfigCommand($this->deploymentConfigMock); 28 | $this->commandTester = new CommandTester($command); 29 | } 30 | 31 | public function testExecute() 32 | { 33 | 34 | $this->deploymentConfigMock->expects($this->once()) 35 | ->method('get') 36 | ->with(ConfigOptionsList::CONFIG_PATH_CUSTOM_OPTION) 37 | ->willReturn('value'); 38 | 39 | $this->commandTester->execute([]); 40 | $this->assertContains('value', $this->commandTester->getDisplay()); 41 | } 42 | 43 | public function testExecuteNoValue() 44 | { 45 | $this->deploymentConfigMock->expects($this->once()) 46 | ->method('get') 47 | ->with(ConfigOptionsList::CONFIG_PATH_CUSTOM_OPTION) 48 | ->willReturn(null); 49 | 50 | $this->commandTester->execute([]); 51 | $this->assertContains('is not set', $this->commandTester->getDisplay()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sample-module-webflow/README.md: -------------------------------------------------------------------------------- 1 | ## Synopsis 2 | 3 | This extension contains a simple demonstrate of two page linked together in a flow. The example can be accessed at the following url: 4 | 5 | `/webflow/firstpage` 6 | 7 | ## Motivation 8 | 9 | This extension demonstrate how to link from one webpage to another using Magento's Url framework. 10 | 11 | ## Technical feature 12 | 13 | ### Url Argument 14 | 15 | [The layout file for the first page](view/frontend/layout/webflow_firstpage_index.xml) defines the block that controls 16 | the page's content in the element. In the element, can contain multiple elements 17 | that can be injected into the block's constructor via the $data array. See [Magento 2 Dev Docs](http://devdocs.magento.com/guides/v1.0/extension-dev-guide/depend-inj.html#dep-inj-mod-type-args) 18 | for information about argument injection. 19 | 20 | Because the argument name does not match any parameter names in the constructor, it goes into the data array and is 21 | accessed by the getData() method. 22 | 23 | ### Magento\Framework\UrlInterface 24 | 25 | An argument of type url has a path attribute. During runtime, Magento\Framework\UrlInterface is given this path, and 26 | generates a full URL corresponding to it. This url is the value that gets injected. 27 | 28 | ## Installation 29 | 30 | This module is intended to be installed using composer. 31 | After the code is marshalled by composer, enable the module by adding it the list of enabled modules in 32 | [Magento configuration](app/etc/config.php) or, if that file does not exist, installing Magento. 33 | After including this component and enabling it, you can verify it is installed by going the backend at: 34 | 35 | STORES -> Configuration -> ADVANCED/Advanced -> Disable Modules Output 36 | 37 | Once there check that the module name shows up in the list to confirm that it was installed correctly. 38 | 39 | ## Tests 40 | 41 | Unit tests are found in the [Test/Unit](Test/Unit) directory. 42 | 43 | ## Contributors 44 | 45 | Magento Core team 46 | 47 | ## License 48 | 49 | [Open Source License](LICENSE.txt) 50 | -------------------------------------------------------------------------------- /sample-module-custom-deployment-config/Console/Command/ShowCustomDeploymentConfigCommand.php: -------------------------------------------------------------------------------- 1 | deploymentConfig = $deploymentConfig; 34 | parent::__construct(); 35 | } 36 | 37 | /** 38 | * {@inheritdoc} 39 | */ 40 | protected function configure() 41 | { 42 | $this->setName('example:custom-deployment-config:show') 43 | ->setDescription('Shows custom deployment configuration option'); 44 | 45 | parent::configure(); 46 | } 47 | 48 | /** 49 | * {@inheritdoc} 50 | */ 51 | protected function execute(InputInterface $input, OutputInterface $output) 52 | { 53 | $value = $this->deploymentConfig->get(ConfigOptionsList::CONFIG_PATH_CUSTOM_OPTION); 54 | if ($value) { 55 | $output->writeln( 56 | 'The custom deployment configuration value is ' . $value . '' 57 | ); 58 | } else { 59 | $output->writeln('The custom deployment configuration value is not set.'); 60 | } 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /sample-external-links/Api/Data/ExternalLinkInterface.php: -------------------------------------------------------------------------------- 1 | className, 'Magento\Framework\App\Action\Action', true)) { 28 | throw new \Exception("AbstractWebflowControllerTest can not be used to test $this->className."); 29 | } 30 | 31 | // Mock dependencies 32 | $this->page = $this->getMockBuilder('Magento\Framework\View\Result\Page') 33 | ->disableOriginalConstructor() 34 | ->getMock(); 35 | $this->resultPageFactory = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory') 36 | ->disableOriginalConstructor() 37 | ->getMock(); 38 | 39 | // Set up SUT 40 | $this->objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); 41 | $this->controller = $this->objectManager->getObject( 42 | $this->className, 43 | ['resultPageFactory' => $this->resultPageFactory] 44 | ); 45 | } 46 | 47 | public function testExecute() 48 | { 49 | // Define test expectations 50 | $this->resultPageFactory->expects($this->once())->method('create')->willReturn($this->page); 51 | $this->assertSame($this->page, $this->controller->execute()); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /sample-module-webapi-client/view/frontend/templates/filter.phtml: -------------------------------------------------------------------------------- 1 | 8 | 9 |
10 |
11 | 12 |
13 | 22 |
23 |
24 |
25 | 26 |
27 | 35 |
36 |
37 |
38 | 39 | 40 |
41 | 42 |
43 |
44 |
45 | -------------------------------------------------------------------------------- /sample-module-service-contract-client/view/frontend/templates/service_contract_client.phtml: -------------------------------------------------------------------------------- 1 | 10 | getProducts(); 13 | /** @var \Magento\Catalog\Api\Data\ProductTypeInterface[] $productTypes */ 14 | $productTypes = $block->getProductTypes(); 15 | ?> 16 |
17 |
18 |
19 | 20 | 28 | 29 |
30 |
31 |
32 | getTotalCount()) : ?> 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | getItems() as $product) : ?> 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 |
SKUNameType
escapeHtml($product->getSku()) ?>escapeHtml($product->getName()) ?>escapeHtml($productTypes[$product->getTypeId()]['label']) ?>
51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /sample-external-links/Tests/Unit/Model/ExternalLinks/ProviderTest.php: -------------------------------------------------------------------------------- 1 | entityManager = $this->getMockBuilder(EntityManager::class) 31 | ->disableOriginalConstructor() 32 | ->getMock(); 33 | $this->loader = $this->getMockBuilder(Loader::class) 34 | ->disableOriginalConstructor() 35 | ->getMock(); 36 | $this->externalLinkFactory = $this->getMockBuilder(ExternalLinkFactory::class) 37 | ->disableOriginalConstructor() 38 | ->getMock(); 39 | $this->provider = new Provider( 40 | $this->entityManager, 41 | $this->loader, 42 | $this->externalLinkFactory 43 | ); 44 | } 45 | 46 | public function testGetExternalLinks() 47 | { 48 | $ids = [1, 2]; 49 | $productId = 3; 50 | $this->loader->expects($this->once()) 51 | ->method("getIdsByProductId") 52 | ->with($productId) 53 | ->willReturn($ids); 54 | 55 | $this->externalLinkFactory->expects($this->exactly(2)) 56 | ->method("create"); 57 | $this->entityManager->expects($this->exactly(2)) 58 | ->method("load"); 59 | 60 | $this->provider->getLinks($productId); 61 | } 62 | } 63 | 64 | 65 | -------------------------------------------------------------------------------- /sample-module-command/Console/Command/GreetingCommand.php: -------------------------------------------------------------------------------- 1 | setName('example:greeting') 41 | ->setDescription('Greeting command') 42 | ->setDefinition([ 43 | new InputArgument( 44 | self::NAME_ARGUMENT, 45 | InputArgument::OPTIONAL, 46 | 'Name' 47 | ), 48 | new InputOption( 49 | self::ALLOW_ANONYMOUS, 50 | '-a', 51 | InputOption::VALUE_NONE, 52 | 'Allow anonymous' 53 | ), 54 | 55 | ]); 56 | 57 | parent::configure(); 58 | } 59 | 60 | /** 61 | * {@inheritdoc} 62 | */ 63 | protected function execute(InputInterface $input, OutputInterface $output) 64 | { 65 | $name = $input->getArgument(self::NAME_ARGUMENT); 66 | $allowAnonymous = $input->getOption(self::ALLOW_ANONYMOUS); 67 | if (is_null($name)) { 68 | if ($allowAnonymous) { 69 | $name = self::ANONYMOUS_NAME; 70 | } else { 71 | throw new \InvalidArgumentException('Argument ' . self::NAME_ARGUMENT . ' is missing.'); 72 | } 73 | } 74 | $output->writeln('Hello ' . $name . '!'); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Request/VoidRequestTest.php: -------------------------------------------------------------------------------- 1 | 'V', 24 | 'TXN_ID' => $txnId, 25 | 'MERCHANT_KEY' => $merchantToken 26 | ]; 27 | 28 | $configMock = $this->getMock(ConfigInterface::class); 29 | $orderMock = $this->getMock(OrderAdapterInterface::class); 30 | $paymentDO = $this->getMock(PaymentDataObjectInterface::class); 31 | $paymentModel = $this->getMockBuilder(Payment::class) 32 | ->disableOriginalConstructor() 33 | ->getMock(); 34 | 35 | $paymentDO->expects(static::once()) 36 | ->method('getOrder') 37 | ->willReturn($orderMock); 38 | $paymentDO->expects(static::once()) 39 | ->method('getPayment') 40 | ->willReturn($paymentModel); 41 | 42 | $paymentModel->expects(static::once()) 43 | ->method('getLastTransId') 44 | ->willReturn($txnId); 45 | 46 | $orderMock->expects(static::any()) 47 | ->method('getStoreId') 48 | ->willReturn($storeId); 49 | 50 | $configMock->expects(static::once()) 51 | ->method('getValue') 52 | ->with('merchant_gateway_key', $storeId) 53 | ->willReturn($merchantToken); 54 | 55 | /** @var ConfigInterface $configMock */ 56 | $request = new VoidRequest($configMock); 57 | 58 | static::assertEquals( 59 | $expectation, 60 | $request->build(['payment' => $paymentDO]) 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Observer/DataAssignObserverTest.php: -------------------------------------------------------------------------------- 1 | getMockBuilder(Event\Observer::class) 21 | ->disableOriginalConstructor() 22 | ->getMock(); 23 | $event = $this->getMockBuilder(Event::class) 24 | ->disableOriginalConstructor() 25 | ->getMock(); 26 | $paymentMethodFacade = $this->getMock(MethodInterface::class); 27 | $paymentInfoModel = $this->getMock(InfoInterface::class); 28 | $dataObject = new DataObject( 29 | [ 30 | 'transaction_result' => ClientMock::SUCCESS 31 | ] 32 | ); 33 | 34 | $observerContainer->expects(static::atLeastOnce()) 35 | ->method('getEvent') 36 | ->willReturn($event); 37 | $event->expects(static::exactly(2)) 38 | ->method('getDataByKey') 39 | ->willReturnMap( 40 | [ 41 | [AbstractDataAssignObserver::METHOD_CODE, $paymentMethodFacade], 42 | [AbstractDataAssignObserver::DATA_CODE, $dataObject] 43 | ] 44 | ); 45 | 46 | $paymentMethodFacade->expects(static::once()) 47 | ->method('getInfoInstance') 48 | ->willReturn($paymentInfoModel); 49 | 50 | $paymentInfoModel->expects(static::once()) 51 | ->method('setAdditionalInformation') 52 | ->with( 53 | 'transaction_result', 54 | ClientMock::SUCCESS 55 | ); 56 | 57 | $observer = new DataAssignObserver(); 58 | $observer->execute($observerContainer); 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Request/CaptureRequestTest.php: -------------------------------------------------------------------------------- 1 | 'S', 24 | 'TXN_ID' => $txnId, 25 | 'MERCHANT_KEY' => $merchantToken 26 | ]; 27 | 28 | $configMock = $this->getMock(ConfigInterface::class); 29 | $orderMock = $this->getMock(OrderAdapterInterface::class); 30 | $paymentDO = $this->getMock(PaymentDataObjectInterface::class); 31 | $paymentModel = $this->getMockBuilder(Payment::class) 32 | ->disableOriginalConstructor() 33 | ->getMock(); 34 | 35 | $paymentDO->expects(static::once()) 36 | ->method('getOrder') 37 | ->willReturn($orderMock); 38 | $paymentDO->expects(static::once()) 39 | ->method('getPayment') 40 | ->willReturn($paymentModel); 41 | 42 | $paymentModel->expects(static::once()) 43 | ->method('getLastTransId') 44 | ->willReturn($txnId); 45 | 46 | $orderMock->expects(static::any()) 47 | ->method('getStoreId') 48 | ->willReturn($storeId); 49 | 50 | $configMock->expects(static::once()) 51 | ->method('getValue') 52 | ->with('merchant_gateway_key', $storeId) 53 | ->willReturn($merchantToken); 54 | 55 | /** @var ConfigInterface $configMock */ 56 | $request = new CaptureRequest($configMock); 57 | 58 | static::assertEquals( 59 | $expectation, 60 | $request->build(['payment' => $paymentDO]) 61 | ); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /sample-module-payment-gateway/Test/Unit/Gateway/Request/MockDataRequestTest.php: -------------------------------------------------------------------------------- 1 | $forceResultCode 26 | ]; 27 | 28 | $paymentDO = $this->getMock(PaymentDataObjectInterface::class); 29 | $paymentModel = $this->getMock(InfoInterface::class); 30 | 31 | 32 | $paymentDO->expects(static::once()) 33 | ->method('getPayment') 34 | ->willReturn($paymentModel); 35 | 36 | $paymentModel->expects(static::once()) 37 | ->method('getAdditionalInformation') 38 | ->with('transaction_result') 39 | ->willReturn( 40 | $transactionResult 41 | ); 42 | 43 | $request = new MockDataRequest(); 44 | 45 | static::assertEquals( 46 | $expectation, 47 | $request->build(['payment' => $paymentDO]) 48 | ); 49 | } 50 | 51 | /** 52 | * @return array 53 | */ 54 | public function transactionResultsDataProvider() 55 | { 56 | return [ 57 | [ 58 | 'forceResultCode' => ClientMock::SUCCESS, 59 | 'transactionResult' => null 60 | ], 61 | [ 62 | 'forceResultCode' => ClientMock::SUCCESS, 63 | 'transactionResult' => ClientMock::SUCCESS 64 | ], 65 | [ 66 | 'forceResultCode' => ClientMock::FAILURE, 67 | 'transactionResult' => ClientMock::FAILURE 68 | ] 69 | ]; 70 | } 71 | } 72 | --------------------------------------------------------------------------------