2017 © Pedro Peláez
 

sylius-plugin sylius-product-bundles-plugin

Plugin for Sylius to configure bundles for products that can be sold together

image

solutiondrive/sylius-product-bundles-plugin

Plugin for Sylius to configure bundles for products that can be sold together

  • Tuesday, April 10, 2018
  • by sd_alt
  • Repository
  • 9 Watchers
  • 12 Stars
  • 1,325 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 9 Versions
  • 35 % Grown

The README.md

, (*1)

Sylius Product Bundles Plugin

License Packagist Build Status Scrutinizer Code Quality, (*2)

Installation

  1. Run composer create-project sylius/plugin-skeleton ProjectName., (*3)

  2. From the plugin skeleton root directory, run the following commands:, (*4)

    $ (cd tests/Application && yarn install)
    $ (cd tests/Application && yarn run gulp)
    $ (cd tests/Application && bin/console assets:install web -e test)
    
    $ (cd tests/Application && bin/console doctrine:database:create -e test)
    $ (cd tests/Application && bin/console doctrine:schema:create -e test)
    

Definition

ProductBundle

ProductBundles are a independent resource and have a OneToOne-relationship with a Product that represents the bundle throughout the sylius-framework, e.g. for calculating prices and taxes in the checkout. The content of a ProductBundle is organized in ProductBundleSlots. One ProductBundle can have 1 to n ProductBundleSlots., (*5)

ProductBundleSlots

ProductBundleSlots represent a group of products that can be switched through by the customer. E.g. in a Bundle for football-Teams there could be a Slot 'Shirts', in which different kinds of shirts can be referenced. Only one item of each ProductBundleSlot is part of the finally bought bundle., (*6)

Usage

ProductBundleCreator

This is a service to create ProductBundles programmatically. It will only create Objects necessary for the ProductBundle. It won't create products for you. But if you have the products that should be part of the bundle you want to create, they can be associated with the created bundle and the slots inside the bundle., (*7)

get the service

$bundleCreator = $container->get('solutiondrive.product_bundles.product_bundle_creator');

create your bundle


$slotOptionsFactory = new solutionDrive\SyliusProductBundlesPlugin\Factory\ProductBundleSlotOptionsFactory(); $hatSlotOptions = $slotOptionsFactory->createNewWithValues(1, 'TopHats'); $shirtSlotOptions = $slotOptionsFactory->createNewWithValues(2, 'Shirts', ['someAdditionalOption' => 'AndItsValue']); $bundleCreator->createProductBundle('YourAwesomeBundle', $prductRepresentationOfTheBundle); $bundleCreator->addSlot('YourAwsomeHats', $hatSlotOptions, $hatsToAssignToSlot); $bundleCreator->addSlot('YourAwsomeShirts', $shirtSlotOptions, $shirtsToAssignToSlot); $productBundle = $bundleCreator->getProductBundle();

Fixtures

Sometimes you'll need to set up your environment quickly and add some default bundles. You can take a look at tests/Application/app/config/fixtures.yml file to see how you can configure fixtures., (*8)

Running plugin tests

  • PHPUnit, (*9)

    $ bin/phpunit
    
  • PHPSpec, (*10)

    $ bin/phpspec run
    
  • Behat (non-JS scenarios), (*11)

    $ bin/behat --tags="~@javascript"
    
  • Behat (JS scenarios), (*12)

    1. Download Chromedriver, (*13)

    2. Run Selenium server with previously downloaded Chromedriver:, (*14)

      $ bin/selenium-server-standalone -Dwebdriver.chrome.driver=chromedriver
      
    3. Run test application's webserver on localhost:8080:, (*15)

      $ (cd tests/Application && bin/console server:run 127.0.0.1:8080 -d web -e test)
      
    4. Run Behat:, (*16)

      $ bin/behat --tags="@javascript"
      

Opening Sylius with your plugin

  • Using test environment:, (*17)

    $ (cd tests/Application && bin/console sylius:fixtures:load -e test)
    $ (cd tests/Application && bin/console server:run -d web -e test)
    
  • Using dev environment:, (*18)

    $ (cd tests/Application && bin/console sylius:fixtures:load -e dev)
    $ (cd tests/Application && bin/console server:run -d web -e dev)
    

The Versions