Seamless Integration: Unifying Magento and ERP for Streamlined Operations

Introduction: In the fast-paced world of e-commerce, businesses require robust systems to manage their operations effectively. Two essential components of any successful online business are a reliable e-commerce platform like Magento and an efficient Enterprise Resource Planning (ERP) system. Integrating Magento with an ERP system can streamline operations, enhance efficiency, and provide a seamless experience for both businesses and customers. This article explores the benefits and strategies behind integrating Magento with ERP, highlighting how this integration can lead to streamlined operations and improved business outcomes.

  1. Understanding Magento and ERP:
    • Overview of Magento: Briefly introduce Magento as a popular e-commerce platform known for its flexibility, scalability, and extensive feature set.
    • Overview of ERP: Explain the concept of an ERP system, which integrates various business functions such as inventory management, order processing, finance, and customer relationship management into a centralized system.
  2. The Need for Integration:
    • Eliminating Data Silos: Discuss the challenges businesses face when data is fragmented across multiple systems, leading to inefficiencies and inaccuracies.
    • Streamlining Operations: Highlight how integrating Magento with ERP enables real-time data synchronization, automated processes, and centralized management, resulting in streamlined operations.
    • Enhanced Visibility and Reporting: Explain how integration provides businesses with a holistic view of their operations, allowing for better decision-making and data-driven insights.
  3. Benefits of Magento-ERP Integration:
    • Inventory Management: Explore how integrating Magento with ERP optimizes inventory control, stock levels, and order fulfillment, minimizing stockouts and reducing carrying costs.
    • Order Processing and Fulfillment: Discuss how integration facilitates seamless order processing, from order placement to shipment tracking, ensuring accurate and timely deliveries.
    • Customer Management: Explain how a unified view of customer data across Magento and ERP systems allows for personalized experiences, efficient support, and targeted marketing campaigns.
    • Financial Management: Highlight the benefits of integrating financial data, such as sales, invoices, and payments, ensuring accurate accounting and streamlined financial processes.
  4. Strategies for Successful Integration:
    • System Evaluation: Provide guidance on selecting the right ERP system that aligns with business requirements and seamlessly integrates with Magento.
    • Data Mapping and Synchronization: Discuss the importance of mapping data fields between Magento and ERP, ensuring accurate and synchronized data transfer.
    • API Integration and Middleware: Explain the role of APIs and middleware solutions in facilitating smooth communication and data exchange between Magento and ERP systems.
    • Testing and Maintenance: Emphasize the need for thorough testing and ongoing maintenance to ensure the integration remains robust and error-free.
  5. Real-world Success Stories:
    • Showcase examples of businesses that have successfully integrated Magento with ERP systems, highlighting their achievements and the specific benefits they have gained.
    • Discuss the challenges faced during implementation, lessons learned, and best practices for other businesses considering integration.

Conclusion: Integrating Magento with an ERP system provides businesses with a comprehensive solution for managing their e-commerce operations efficiently. By eliminating data silos, streamlining processes, and enhancing visibility, businesses can achieve seamless operations, improved customer experiences, and better decision-making capabilities. As e-commerce continues to evolve, Magento-ERP integration becomes an indispensable tool for businesses seeking to stay competitive and drive growth in the digital marketplace.

yarn 00h00m00s 0/0: : ERROR: There are no scenarios; must have at least one.

The error message you encountered with Yarn stating “ERROR: There are no scenarios; must have at least one” suggests that there are no scenarios defined in your Yarn configuration. To resolve this issue, you can follow these steps:

  1. Check the Yarn configuration: Verify that your Yarn configuration file (usually yarn.yml or yarn.json) exists and is properly configured. Look for any sections related to scenarios or scenario definitions.
  2. Define a scenario: If you don’t have any scenarios defined in your configuration file, add at least one scenario. A scenario defines a specific set of conditions or steps for Yarn to follow. It can include inputs, commands, or other configuration parameters based on your requirements.
  3. Ensure correct syntax: Make sure the scenario definition in your configuration file follows the correct syntax and structure as specified in the Yarn documentation. Double-check for any typos or formatting errors that may be causing the error message.
  4. Save the changes: Save the updated configuration file once you have defined the scenario(s). Ensure that the file is saved in the correct location and that Yarn can access it.
  5. Run Yarn with the scenario: Execute the Yarn command that corresponds to the scenario you defined. For example, if you named your scenario “myScenario,” you might run yarn run myScenario. This will instruct Yarn to use the specified scenario for the current operation.
  6. Verify the outcome: Check if the error message is resolved and if Yarn behaves as expected with the defined scenario. Review the logs or any output provided by Yarn to ensure that the scenario is being recognized and executed correctly.

By following these steps, you should be able to resolve the error related to the absence of scenarios in Yarn and successfully utilize the defined scenarios for your project.

How to Install MariaDB on Ubuntu: A Step-by-Step Guide

Title: How to Install MariaDB on Ubuntu: A Comprehensive Guide for Professionals

Introduction: This comprehensive guide provides step-by-step instructions on installing MariaDB on a Vultr Ubuntu cloud server. Suitable for professionals, this guide is applicable to Ubuntu 16.04 through Ubuntu 20.10 LTS versions. MariaDB, a robust and feature-rich relational database management system, serves as a drop-in replacement for MySQL.

  1. Deploying Ubuntu Server Before proceeding with the installation, deploy a new instance of the Ubuntu Vultr cloud server. Follow the best practices guides listed below to ensure a secure and optimized setup:
  • Create a sudo user
  • Update the Ubuntu server
  • Switch to the sudo user for the remaining steps
  1. Installing MariaDB To install MariaDB and set it up as a replacement for MySQL, execute the following commands in the terminal:
$ sudo apt install mariadb-server mariadb-client -y

Enable MariaDB to start automatically during system boot with the following command:

$ sudo systemctl enable mariadb.service

To secure the MariaDB installation, run the MySQL Secure Installation script:

$ sudo mysql_secure_installation

During the script execution, respond to the security questions as follows:

  • For the initial root password, press ENTER as there is no password set.
  • When prompted, set a new password for the root account and confirm it.
  • Press ENTER to remove the anonymous user.
  • Disallow remote root logins by pressing ENTER.
  • Press ENTER to remove the test database.
  • Reload the privilege tables by pressing ENTER.
  1. Testing the Installation Ensure the installation was successful by connecting to the MariaDB server as the root user:
$ mysql -u root -p -h localhost

Within the MariaDB client, create a test user and a test database:

> CREATE USER 'test_user'@'localhost' IDENTIFIED BY 'test_pass';
> CREATE DATABASE test_database;

Grant the test user all privileges on the test database:

> GRANT ALL PRIVILEGES ON test_database.* TO 'test_user'@'localhost';

Exit the MariaDB client:

> quit

Conclusion: Congratulations! You have successfully installed MariaDB on a Vultr Ubuntu cloud server. For further information and advanced usage, refer to the official MariaDB documentation.

For more details, visit: Link to official MariaDB documentation

How to Install MariaDB on Ubuntu?

Follow up above steps.

Adding TIMESTAMP_INIT as a Default Value in Declarative Schema

 Introduction:

When working with databases, it’s often essential to track the timestamp of various operations such as record creation or modification. Magento 2, a popular e-commerce platform, introduced the Declarative Schema approach to simplify database setup and maintenance. In this article, we will explore how to add the TIMESTAMP_INIT value as a default value using the Declarative Schema in Magento 2.

Understanding Declarative Schema:
Declarative Schema is a powerful feature in Magento 2 that allows developers to define and manage database structures using XML files. It provides a structured way of creating and updating database tables, columns, indexes, and other elements. The schema is defined in a declarative manner, which means developers specify what the database should look like, and Magento handles the necessary database operations automatically.

Adding TIMESTAMP_INIT as a Default Value:
To add TIMESTAMP_INIT as a default value in the Declarative Schema, follow these steps:

Step 1: Create a new file or modify an existing one:
In your Magento module, navigate to the etc/db_schema.xml file or create one if it doesn’t exist.

Step 2: Define the table structure:
Inside the <schema> tag, define your table structure using the <table> tag. For example, let’s say we have a table called example_table with a column named created_at that we want to set with the TIMESTAMP_INIT value.

Step 3: Add the column declaration:
Within the <table> tag, add a <column> tag for the created_at column. Specify the column name, type, and length as per your requirements.

xml
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" comment="Created At"/>

Here, on_update="false" ensures that the created_at column won’t update automatically when the record is modified.

Step 4: Set the default value:
To set TIMESTAMP_INIT as the default value, include the default="TIMESTAMP_INIT" attribute in the <column> tag.

xml
<column xsi:type="timestamp" name="created_at" on_update="false" nullable="false" default="TIMESTAMP_INIT" comment="Created At"/>

Step 5: Complete the db_schema.xml file:
Save the db_schema.xml file with the complete table and column definitions.

Step 6: Run the database upgrade:
To apply the changes, run the following command from the Magento root directory:

arduino
bin/magento setup:upgrade

This command triggers the installation and upgrade process, which executes the Declarative Schema changes.

Conclusion:
By following the steps outlined in this article, you can easily add the TIMESTAMP_INIT value as a default value in the Declarative Schema of your Magento 2 module. Leveraging Declarative Schema simplifies the management of database structures and ensures consistent database operations across different environments.

Puneet Kumar Magento Developer

To call a static block into a GraphQL query in the Alpine.js

 To call a static block into a GraphQL query in the Alpine.js framework within Magento 2, you would need to follow these steps:

  1. Create a GraphQL query:

    • Define your query in the app/code/{Vendor}/{Module}/etc/graphql/schema.graphqls file. For example:

      graphql
      type Query { staticBlock(identifier: String!): String @resolver(class: "{Vendor}\{Module}\Model\Resolver\StaticBlock") @doc(description: "Retrieve the content of a static block by identifier") }
  2. Create a Resolver class:

    • Create the resolver class app/code/{Vendor}/{Module}/Model/Resolver/StaticBlock.php. In this class, you will define the logic to retrieve the static block content. Here’s an example implementation:

      php
      <?php namespace {Vendor}{Module}ModelResolver; use MagentoCmsModelBlockRepository; use MagentoFrameworkExceptionNoSuchEntityException; use MagentoFrameworkGraphQlQueryResolverInterface; use MagentoFrameworkGraphQlQueryResolverContextInterface; class StaticBlock implements ResolverInterface { private $blockRepository; public function __construct(BlockRepository $blockRepository) { $this->blockRepository = $blockRepository; } public function resolve( ContextInterface $context, array $args, array $directives = [], GraphQLTypeDefinitionResolveInfo $info = null ) { $identifier = $args['identifier']; try { $block = $this->blockRepository->getByIdentifier($identifier); return $block->getContent(); } catch (NoSuchEntityException $e) { return null; } } }
  3. Utilize the GraphQL query in Alpine.js:

    • In your Alpine.js component, make an HTTP request to the GraphQL endpoint to fetch the static block content. Here’s an example using Axios:

      javascript
      <template> <div x-data="{ blockContent: '' }"> <div x-html="blockContent"></div> </div> </template> <script> import axios from 'axios'; export default { mounted() { axios.post('/graphql', { query: ` query { staticBlock(identifier: "your_block_identifier") } `, }) .then(response => { this.blockContent = response.data.data.staticBlock; }) .catch(error => { console.error(error); }); }, } </script>

Ensure to replace {Vendor} and {Module} with your actual vendor and module names, respectively. Also, replace "your_block_identifier" with the identifier of the static block you want to retrieve.

Remember to adjust the code according to your specific requirements and ensure that you have appropriate permissions and configurations set up for GraphQL and the Alpine.js framework in your Magento 2 installation.

Puneet Kumar Magento Developer

Credit Card Flow | Magento Braintree | Paypal Payflow Pro | Pk Magento 2

Credit Card Flow | Magento Braintree | Paypal Payflow Pro 

 

  1. Users add products in cart then move on checkout. 

  1. User full fill all required fields then select shipping method and payment method 

  1. If payment is selected as Braintree credit card. Then user enters card details 

  1. Then Magento to validate all other field data like billing address, shipping address and shipping method etc.  

 

  1. Then User clicks on place order button.  

 

  1. Magento sends validation request to Braintree with Braintree (Merchant) credentials and Card Details. 

  1. After successful validation, Braintree sends back response token to Magento on real-time. 

  1. Magento now sends “Token, customer details & order details” to Braintree. 

*details like customer billing & shipping address, item total, discount., order ID etc. 

  1. Braintree validates the card details through token and charge the amount to customer and sends back response to Magento in real-time with below responses 

  1. Success – Response contains Success array  

  1. False– Response contains the Error details 

  1. Null – Blank Array with no details  

“Null” response is not handled currently which needs to be solutionized 

 

 

 

 

Request example in json. 

 

‘request’ =>  

  array ( 

    ‘customer’ =>  

    array ( 

      ‘firstName‘ => ‘xxrri-xxynn’, 

      ‘lastName‘ => ‘McKillop’, 

      ‘company’ => ”, 

      ‘phone’ => ‘xxxxxxx’, 

      ’email’ => ‘xxxx@outlook.com’, 

    ), 

    ‘amount’ => ‘189.99’, 

    ‘paymentMethodNonce‘ => ‘tokencc_bd_wyn4wk_657vx3_gfkg9s_t85xkq_vr3’, 

    ‘orderId‘ => ‘xx171241xxx38921’, 

    ‘channel’ => ‘MagxxxxxeneBT’, 

    ‘options’ =>  

    array ( 

      ‘skipAdvancedFraudChecking‘ => false, 

      ‘storeInVaultOnSuccess‘ => true, 

      ‘submitForSettlement‘ => true, 

    ), 

    ‘customFields‘ =>  

    array ( 

    ), 

    ‘billing’ =>  

    array ( 

      ‘firstName‘ => ‘Terri-Lynn’, 

      ‘lastName‘ => ‘McKillop’, 

      ‘company’ => ”, 

      ‘streetAddress‘ => ‘724 xxxtherine Street’, 

      ‘extendedAddress‘ => ”, 

      ‘locality’ => ‘thunder bay’, 

      ‘region’ => ‘ON’, 

      ‘postalCode‘ => ‘p7xxx’, 

      ‘countryCodeAlpha2’ => ‘CA’, 

    ), 

    ‘shipping’ =>  

    array ( 

      ‘firstName‘ => ‘Terri-Lynn’, 

      ‘lastName‘ => ‘McKillop’, 

      ‘company’ => NULL, 

      ‘streetAddress‘ => ‘724 Catherine Street’, 

      ‘extendedAddress‘ => ”, 

      ‘locality’ => ‘thunder bay’, 

      ‘region’ => ‘ON’, 

      ‘postalCode‘ => ‘p7e1l5’, 

      ‘countryCodeAlpha2’ => ‘CA’, 

      ‘countryCodeAlpha3’ => ‘CAN’, 

    ), 

    ‘purchaseOrderNumber‘ => ‘xxx’, 

    ‘taxAmount‘ => ‘21.86’, 

    ‘discountAmount‘ => ‘137.57’,     

           

 

Response sample 

 

 

Null 

 

Failed 

 

 

Response sample  

‘client’ => ‘PayPal\Braintree\Gateway\Http\Client\TransactionSale‘, 

  ‘response’ =>  

  array ( 

    ‘success’ => true, 

    ” . “” . ‘Braintree\Result\Successful‘ .” . ‘_returnObjectNames‘ =>  

    array ( 

      0 => ‘transaction’, 

    ), 

    ” . “” . ‘*’ . “” . ‘_attributes’ =>  

    array ( 

    ), 

    ‘transaction’ =>  

    BraintreeTransaction::__set_state(array( 

       ‘_attributes’ =>  

      array ( 

        ‘id’ => ‘xxxx‘, 

        ‘status’ => ‘submitted_for_settlement‘, 

        ‘type’ => ‘sale’, 

        ‘currencyIsoCode‘ => ‘USD’, 

        ‘amount’ => ‘19.95’, 

        ‘amountRequested‘ => ‘19.95’, 

        ‘merchantAccountId‘ => ‘xxxxxx‘, 

        ‘subMerchantAccountId‘ => NULL, 

        ‘masterMerchantAccountId‘ => NULL, 

        ‘orderId‘ => ‘xxxxx’, 

        ‘createdAt‘ =>  

        DateTime::__set_state(array( 

           ‘date’ => ‘2022-09-02 18:45:31.000000’, 

           ‘timezone_type‘ => 3, 

           ‘timezone‘ => ‘UTC’, 

        )), 

        ‘updatedAt‘ =>  

        DateTime::__set_state(array( 

           ‘date’ => ‘2022-09-02 18:45:32.000000’, 

           ‘timezone_type‘ => 3, 

           ‘timezone‘ => ‘UTC’, 

        )), 

        ‘customer’ =>  

        array ( 

          ‘id’ => ‘xxxx’, 

          ‘firstName‘ => ‘xxxx’, 

          ‘lastName‘ => ‘Wasserman’, 

          ‘company’ => NULL, 

          ’email’ => ‘xxxxx@gmail.com’, 

          ‘website’ => NULL, 

          ‘phone’ => ‘xxxxxxx’, 

          ‘fax’ => NULL, 

          ‘globalId‘ => ‘xxxxxx’, 

        ), 

        ‘billing’ =>  

        array ( 

          ‘id’ => NULL, 

          ‘firstName‘ => ‘Amanda’, 

          ‘lastName‘ => ‘xxxxx’, 

          ‘company’ => NULL, 

          ‘streetAddress‘ => ‘1008 xxxx Ave’, 

          ‘extendedAddress‘ => NULL, 

          ‘locality’ => ‘Ann Arbor’, 

          ‘region’ => ‘MI’, 

          ‘postalCode‘ => ‘xxx’, 

          ‘countryName‘ => ‘United States of America’, 

          ‘countryCodeAlpha2’ => ‘US’, 

          ‘countryCodeAlpha3’ => ‘USA’, 

          ‘countryCodeNumeric‘ => ‘840’, 

        ), 

        ‘refundId‘ => NULL, 

        ‘refundIds‘ =>  

        array ( 

        ), 

        ‘refundedTransactionId‘ => NULL, 

        ‘partialSettlementTransactionIds‘ =>  

        array ( 

        ), 

        ‘authorizedTransactionId‘ => NULL, 

        ‘settlementBatchId‘ => NULL, 

        ‘shipping’ =>  

        array ( 

          ‘id’ => NULL, 

          ‘firstName‘ => ‘Amanda’, 

          ‘lastName‘ => ‘Wasserman’, 

          ‘company’ => NULL, 

          ‘streetAddress‘ => ‘1008 Oakland Ave’, 

          ‘extendedAddress‘ => NULL, 

          ‘locality’ => ‘Ann Arbor’, 

          ‘region’ => ‘MI’, 

          ‘postalCode‘ => ‘48104’, 

          ‘countryName‘ => ‘United States of America’, 

          ‘countryCodeAlpha2’ => ‘US’, 

          ‘countryCodeAlpha3’ => ‘USA’, 

          ‘countryCodeNumeric‘ => ‘840’, 

        ), 

        ‘customFields‘ => NULL, 

        ‘accountFundingTransaction‘ => false, 

        ‘avsErrorResponseCode‘ => NULL, 

        ‘avsPostalCodeResponseCode‘ => ‘N’, 

        ‘avsStreetAddressResponseCode‘ => ‘N’, 

        ‘cvvResponseCode‘ => ‘M’, 

        ‘gatewayRejectionReason‘ => NULL, 

        ‘processorAuthorizationCode‘ => ‘006390’, 

        ‘processorResponseCode‘ => ‘1000’, 

        ‘processorResponseText‘ => ‘Approved’, 

        ‘additionalProcessorResponse‘ => NULL, 

        ‘voiceReferralNumber‘ => NULL, 

        ‘purchaseOrderNumber‘ => ‘xxxx’, 

        ‘taxAmount‘ => ‘0.00’, 

        ‘taxExempt‘ => false, 

        ‘scaExemptionRequested‘ => NULL, 

        ‘processedWithNetworkToken‘ => false, 

        ‘creditCard‘ =>  

        array ( 

          ‘token’ => ‘xxxxx’, 

          ‘bin’ => ‘436618’, 

          ‘last4’ => ‘6871’, 

          ‘cardType‘ => ‘Visa’, 

          ‘expirationMonth‘ => ’08’, 

          ‘expirationYear‘ => ‘2026’, 

          ‘customerLocation‘ => ‘US’, 

          ‘cardholderName‘ => NULL, 

          ‘imageUrl‘ => ‘https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=production’, 

          ‘prepaid’ => ‘No’, 

          ‘healthcare’ => ‘No’, 

          ‘debit’ => ‘Yes’, 

          ‘durbinRegulated‘ => ‘Yes’, 

          ‘commercial’ => ‘Unknown’, 

          ‘payroll’ => ‘No’, 

          ‘issuingBank‘ => ‘U.S. Bank National Association’, 

          ‘countryOfIssuance‘ => ‘USA’, 

          ‘productId‘ => ‘F’, 

          ‘globalId‘ => ‘xxxxx’, 

          ‘accountType‘ => ‘credit’, 

          ‘uniqueNumberIdentifier‘ => ‘xxxx’, 

          ‘venmoSdk‘ => false, 

          ‘accountBalance‘ => NULL, 

        ), 

        ‘statusHistory‘ =>  

        array ( 

          0 =>  

          BraintreeTransactionStatusDetails::__set_state(array( 

             ‘_attributes’ =>  

            array ( 

              ‘timestamp’ =>  

              DateTime::__set_state(array( 

                 ‘date’ => ‘2022-09-02 18:45:31.000000’, 

                 ‘timezone_type‘ => 3, 

                 ‘timezone‘ => ‘UTC’, 

              )), 

              ‘status’ => ‘authorized’, 

              ‘amount’ => ‘19.95’, 

              ‘user’ => ‘vivyx_bt‘, 

              ‘transactionSource‘ => ‘api‘, 

            ), 

          )), 

          1 =>  

          BraintreeTransactionStatusDetails::__set_state(array( 

             ‘_attributes’ =>  

            array ( 

              ‘timestamp’ =>  

              DateTime::__set_state(array( 

                 ‘date’ => ‘2022-09-02 18:45:31.000000’, 

                 ‘timezone_type‘ => 3, 

                 ‘timezone‘ => ‘UTC’, 

              )), 

              ‘status’ => ‘submitted_for_settlement‘, 

              ‘amount’ => ‘19.95’, 

              ‘user’ => ‘vivyx_bt‘, 

              ‘transactionSource‘ => ‘api‘, 

            ), 

          )), 

        ), 

        ‘planId‘ => NULL, 

        ‘subscriptionId‘ => NULL, 

        ‘subscription’ =>  

        array ( 

          ‘billingPeriodEndDate‘ => NULL, 

          ‘billingPeriodStartDate‘ => NULL, 

        ), 

        ‘addOns‘ =>  

        array ( 

        ), 

        ‘discounts’ =>  

        array ( 

        ), 

        ‘descriptor’ =>  

        BraintreeDescriptor::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘name’ => NULL, 

            ‘phone’ => NULL, 

            ‘url‘ => NULL, 

          ), 

        )), 

        ‘recurring’ => false, 

        ‘channel’ => ‘Magento2GeneBT’, 

        ‘serviceFeeAmount‘ => NULL, 

        ‘escrowStatus‘ => NULL, 

        ‘disbursementDetails‘ =>  

        BraintreeDisbursementDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘disbursementDate‘ => NULL, 

            ‘settlementAmount‘ => NULL, 

            ‘settlementCurrencyIsoCode‘ => NULL, 

            ‘settlementCurrencyExchangeRate‘ => NULL, 

            ‘settlementBaseCurrencyExchangeRate‘ => NULL, 

            ‘fundsHeld‘ => NULL, 

            ‘success’ => NULL, 

          ), 

        )), 

        ‘disputes’ =>  

        array ( 

        ), 

        ‘achReturnResponses‘ =>  

        array ( 

        ), 

        ‘authorizationAdjustments‘ =>  

        array ( 

        ), 

        ‘paymentInstrumentType‘ => ‘credit_card‘, 

        ‘processorSettlementResponseCode‘ => NULL, 

        ‘processorSettlementResponseText‘ => NULL, 

        ‘networkResponseCode‘ => ’00’, 

        ‘networkResponseText‘ => ‘Successful approval/completion or V.I.P. PIN verification is successful’, 

        ‘threeDSecureInfo‘ => NULL, 

        ‘shipsFromPostalCode‘ => ‘30046’, 

        ‘shippingAmount‘ => ‘0.00’, 

        ‘discountAmount‘ => ‘0.00’, 

        ‘networkTransactionId‘ => ‘462245675316191’, 

        ‘processorResponseType‘ => ‘approved’, 

        ‘authorizationExpiresAt‘ =>  

        DateTime::__set_state(array( 

           ‘date’ => ‘2022-09-09 18:45:31.000000’, 

           ‘timezone_type‘ => 3, 

           ‘timezone‘ => ‘UTC’, 

        )), 

        ‘retryIds‘ =>  

        array ( 

        ), 

        ‘retriedTransactionId‘ => NULL, 

        ‘refundGlobalIds‘ =>  

        array ( 

        ), 

        ‘partialSettlementTransactionGlobalIds‘ =>  

        array ( 

        ), 

        ‘refundedTransactionGlobalId‘ => NULL, 

        ‘authorizedTransactionGlobalId‘ => NULL, 

        ‘globalId‘ => ‘xxxxx’, 

        ‘retryGlobalIds‘ =>  

        array ( 

        ), 

        ‘retriedTransactionGlobalId‘ => NULL, 

        ‘retrievalReferenceNumber‘ => NULL, 

        ‘installmentCount‘ => NULL, 

        ‘installments’ =>  

        array ( 

        ), 

        ‘refundedInstallments‘ =>  

        array ( 

        ), 

        ‘responseEmvData‘ => NULL, 

        ‘acquirerReferenceNumber‘ => NULL, 

        ‘merchantIdentificationNumber‘ => ‘xxxxx’, 

        ‘terminalIdentificationNumber‘ => ‘xxxxx’, 

        ‘merchantName‘ => ‘VIVYX PRINTING LLC’, 

        ‘merchantAddress‘ =>  

        array ( 

          ‘streetAddress‘ => NULL, 

          ‘locality’ => ‘Phoenix’, 

          ‘region’ => ‘AZ’, 

          ‘postalCode‘ => ‘85034’, 

          ‘phone’ => ‘6786503559’, 

        ), 

        ‘pinVerified‘ => false, 

        ‘debitNetwork‘ => NULL, 

        ‘processingMode‘ => NULL, 

        ‘paymentReceipt‘ =>  

        array ( 

          ‘id’ => ‘dxzfyakj‘, 

          ‘globalId‘ => ‘dHJhbnNhY3Rpb25fZHh6Znlha2o’, 

          ‘amount’ => ‘19.95’, 

          ‘currencyIsoCode‘ => ‘USD’, 

          ‘processorResponseCode‘ => ‘1000’, 

          ‘processorResponseText‘ => ‘Approved’, 

          ‘processorAuthorizationCode‘ => ‘006390’, 

          ‘merchantName‘ => ‘VIVYX PRINTING LLC’, 

          ‘merchantAddress‘ =>  

          array ( 

            ‘streetAddress‘ => NULL, 

            ‘locality’ => ‘Phoenix’, 

            ‘region’ => ‘AZ’, 

            ‘postalCode‘ => ‘85034’, 

            ‘phone’ => ‘6786503559’, 

          ), 

          ‘merchantIdentificationNumber‘ => ‘4454xxxx96100998’, 

          ‘terminalIdentificationNumber‘ => ‘00000001’, 

          ‘type’ => ‘sale’, 

          ‘pinVerified‘ => false, 

          ‘processingMode‘ => NULL, 

          ‘networkIdentificationCode‘ => NULL, 

          ‘cardType‘ => ‘Visa’, 

          ‘cardLast4’ => ‘6871’, 

          ‘accountBalance‘ => NULL, 

        ), 

        ‘creditCardDetails‘ =>  

        BraintreeTransactionCreditCardDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘token’ => ‘9cjbcfz’, 

            ‘bin’ => ‘436618’, 

            ‘last4’ => ‘6871’, 

            ‘cardType‘ => ‘Visa’, 

            ‘expirationMonth‘ => ’08’, 

            ‘expirationYear‘ => ‘2026’, 

            ‘customerLocation‘ => ‘US’, 

            ‘cardholderName‘ => NULL, 

            ‘imageUrl‘ => ‘https://assets.braintreegateway.com/payment_method_logo/visa.png?environment=production’, 

            ‘prepaid’ => ‘No’, 

            ‘healthcare’ => ‘No’, 

            ‘debit’ => ‘Yes’, 

            ‘durbinRegulated‘ => ‘Yes’, 

            ‘commercial’ => ‘Unknown’, 

            ‘payroll’ => ‘No’, 

            ‘issuingBank‘ => ‘U.S. Bank National Association’, 

            ‘countryOfIssuance‘ => ‘USA’, 

            ‘productId‘ => ‘F’, 

            ‘globalId‘ => ‘cGF5bWVudG1ldGhvZF9jY185Y2piY2Z6’, 

            ‘accountType‘ => ‘credit’, 

            ‘uniqueNumberIdentifier‘ => ‘a5595b292d9ea1e711b4808e3677e4b2’, 

            ‘venmoSdk‘ => false, 

            ‘accountBalance‘ => NULL, 

            ‘expirationDate‘ => ’08/2026’, 

            ‘maskedNumber‘ => ‘436618******6871’, 

          ), 

        )), 

        ‘customerDetails‘ =>  

        BraintreeTransactionCustomerDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘id’ => ‘ccg854cb’, 

            ‘firstName‘ => ‘Amanda’, 

            ‘lastName‘ => ‘Wasserman’, 

            ‘company’ => NULL, 

            ’email’ => ‘awwasserman@gmail.com’, 

            ‘website’ => NULL, 

            ‘phone’ => ‘8589253310’, 

            ‘fax’ => NULL, 

            ‘globalId‘ => ‘Y3VzdG9tZXJfY2NnODU0Y2I’, 

          ), 

        )), 

        ‘billingDetails‘ =>  

        BraintreeTransactionAddressDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘id’ => NULL, 

            ‘firstName‘ => ‘Amanda’, 

            ‘lastName‘ => ‘Wasserman’, 

            ‘company’ => NULL, 

            ‘streetAddress‘ => ‘1008 Oakland Ave’, 

            ‘extendedAddress‘ => NULL, 

            ‘locality’ => ‘Ann Arbor’, 

            ‘region’ => ‘MI’, 

            ‘postalCode‘ => ‘48104’, 

            ‘countryName‘ => ‘United States of America’, 

            ‘countryCodeAlpha2’ => ‘US’, 

            ‘countryCodeAlpha3’ => ‘USA’, 

            ‘countryCodeNumeric‘ => ‘840’, 

          ), 

        )), 

        ‘shippingDetails‘ =>  

        BraintreeTransactionAddressDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘id’ => NULL, 

            ‘firstName‘ => ‘Amanda’, 

            ‘lastName‘ => ‘Wasserman’, 

            ‘company’ => NULL, 

            ‘streetAddress‘ => ‘1008 Oakland Ave’, 

            ‘extendedAddress‘ => NULL, 

            ‘locality’ => ‘Ann Arbor’, 

            ‘region’ => ‘MI’, 

            ‘postalCode‘ => ‘48104’, 

            ‘countryName‘ => ‘United States of America’, 

            ‘countryCodeAlpha2’ => ‘US’, 

            ‘countryCodeAlpha3’ => ‘USA’, 

            ‘countryCodeNumeric‘ => ‘840’, 

          ), 

        )), 

        ‘subscriptionDetails‘ =>  

        BraintreeTransactionSubscriptionDetails::__set_state(array( 

           ‘_attributes’ =>  

          array ( 

            ‘billingPeriodEndDate‘ => NULL, 

            ‘billingPeriodStartDate‘ => NULL, 

          ), 

        )), 

      ), 

    )), 

  ), 

) [] [] 

 

 

 

  1. In case user selects “PayPal” as payment method and places order, then 

  1. It redirects on a controller and generate a redirect URL of Paypal which contains all information regarding payment & redirect URL.   

  1. user gets redirected to “PayPal” website. 

  1. After making payment on “PayPal” website, user is redirected back to Magento website using the redirect URL which also contains the response success and failed.   

  1. Magento will now generate order according to response received 

  1.  If payment is successful, then order will get generated  

  1.  In case payment is failed user gets redirected to cart page as received the failure object on the redirect URL response. 

 

 

 

Puneet Kumar Magento Developer

Magento 2 Design patterns | pk magento 2

 My youtube channel : https://www.youtube.com/channel/UChb7DM9SspzrUVh4hnWL50A

REQUESTED BY : ANKUR PORWAL
01 (MVC)  MODEL VIEW CONTROLLER PATTERN (MVVM) MODEL VIEW VIEWMODEL PATTERN 
Model View Controller, MVC in short. This is a design pattern where business, presentation and coupling logic are separated. Magento utilizing a DOM based configuration layer. It is used xml to drive the configuration and actions of the application on top of the regular Model-View-Controller architecture. 
MVVM design pattern is used in magento on checkout page with knockoutjs. 
02 FRONT CONTROLLER PATTERN
The front controller pattern to implement workflows for our application. It has a single entry point (index.php) for all requests. It have bootstrap file which is decied which controller will call. With (module name) / (folder name) / (Controller class name) with psr-4 stander.  
03 FACTORY PATTERN
The factory Method is using to create class in Magento. We instantiate a class in Magento by calling an appropriate method passing an abstract name repre, jdsenting a class group followed by a class name. Class groups and their appropriate abstractions are declared in our configuration XML files in our module’s /etc/ folder.
04 SINGLETON PATTERN
This is same like factory class abstraction and class groups in Magento, the Singleton pattern is instantiated for Blocks and Classes. It is restricts the instantiate of a class to one object and it is useful to restrict the limited number of connections in a database or limited amount of memory for a particular instance of class.
05 REGISTRY PATTERN
The registry pattern is a pattern that allows any object or data to be available in a public global scope for any resource. All the singleton patterns are stored in the internal registry, a global scoped container for storing data. This pattern is not only for internal use.
06 PROTOTYPE PATTERN
The prototype pattern is used as an extension of the Abstract Factory pattern. It is ensures that an appropriate subclass is instantiated via appropriate types that are assigned to an object.
07 OBJECT POOL PATTERN
The object pool pattern is simply a box with objects so that they don’t have to be allocated and destroyed over and over again. It is keeps objects ready for use over and over again instead of re-instantiating them and destroying them once finished. It is a great way to save on memory consumption.
08 ITERATOR PATTERN
The iterator pattern is a design pattern that allows specify an iterator and allow for multiple different sets of data to be passed without changing the underlying structure that allows the iteration. In Magento, this is handled by the Varien_Data_Collection which turn uses various baked-in PHP classes (like Array Iterator) for having a more Object Orient-interface to arrays. This is ensures that model-collections will always have a common API to iterate over without being dependent of the actual models.
09 LAZY LOADING PATTERN
The lazy Loading is a design pattern that delays the loading of an object until the time that the object is called upon. They don’t utilize with objects with Magento.
10 SERVICE LOCATOR PATTERN
The service locator pattern is a design pattern that allows a user to get a service by encapsulating the process inside an abstraction layer. This is allows the user to retrieve the appropriate or best services without knowing what that service is at runtime.
11 MODULE PATTERN
The module pattern is basically defines that different domains are grouped into separate modules which function independent of each other and can be plugged-in to the main system as deemed appropriate. It is a form of modular programming that emphasizes the grouping of functionality of a program into independent, inter-changeable modules.
12 OBSERVER PATTERN
The observer pattern is set a certain point during an application’s execution. Other components of the application can “hook” into the event listener and execute their code during this point. Magento has its event-driven architecture and it is a result of an implementation of the observer pattern.
THERE ARE SOME ADDITIONAL DESIGN PATTERNS TO USE IN MAGENTO 2
01 SERVICE CONTRACT DESIGN PATTERN
Magento is an extension based system, which allows a third-party modules, which developer to customize and overwrite on the core parts of its framework. These customization may have many several issues, thus to overcome Magento comes up with service contract pattern. It is a set of the interfaces which act as a layers between end users and business layer.
02 OBJECT MANAGER
There is consist of various pattern such as Dependency injection, Singleton, Factory, Abstract Factory, Composite, strategy, CQRS, Decorator and many more. It has a very big role to run, Magento prohibits the direct use of it. Object manager is responsible for the implement singleton, factory and proxy patterns. It is automatically instantiates parameters in class constructors. Before moving future let’s understand about injectable and non-injectable objects.
03 INJECTABLE OBJECTS
They don’t have any own identity such as Event Manager, Customer Account Management Service.
04 NON- INJECTABLE OBJECTS
They entities usually have their identities and state, since they have their identities, such as customer, product etc.
05 DEPENDENCY INJECTION
The dependency injection is an alternative to Mage in Magento 1. It is a concepts of injecting the dependent object through external environment rather than creating them internally. Thus we will be using with resource when our object is being created instead of creating resource when needed. This helps in future modification or customization and testing becomes very easy by mocking required objects.
06 FACTORY PATTERN OR FACTORY CLASSES
The factory classes create a layer between the object manager and business code in Magento 2. It is a classes need not define explicitly as they are auto-generated.
07 PROXY PATTERN
The proxy classes are used to work in place of another class and in Magento 2, they are sometimes used in place of resource needed classes. As per Magento uses constructor injection for object creation and when we instantiate an object all the classes. The constructor will also instantiate thus leading to a chaining of instantiation of the constructor. It can really slow down the process and impact on the performance of an application, however to stop chain instantiation Magento uses proxy classes.
Puneet Kumar Magento Developer

linux rewrite engine on a2enmod rewrite

 Command 

a2enmod rewrite
Puneet Kumar Magento Developer