PHP code example of zero1 / magento2-release-library

1. Go to this page and download the library: Download zero1/magento2-release-library library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

zero1 / magento2-release-library example snippets


/** @var \Zero1\ReleaseLibrary\Utility **/
protected $setupUtility;

public function __construct(
    \Zero1\ReleaseLibrary\Utility $setupUtility
){
    $this->setupUtility = $setupUtility;
}

$this->setupUtility->createCustomVariable(
    'Variable Code,
    'Variable Name',
    'HTML Value',
    'Plain Value'
);

$this->setupUtility->moveCategory(
    CATEGORY_ID_TO_MOVE
    MOVE_TO_THIS_CATEGORY_ID,
);

// configure setup utility to use my module
$this->setupUtility->setSourceModule('My_ReleaseModule);

// create all the blocks in `1.0.1`
$this->setupUtility->createBlocksFromDir(
    $this->setupUtility->getBlockSourceDirectory().'/1.0.1/'
);

// configure setup utility to use my module
$this->setupUtility->setSourceModule('My_ReleaseModule);

// create all the pages in `1.0.1`
$this->setupUtility->createPagesFromDir(
    $this->setupUtility->getPageSourceDirectory().'/1.0.1/'
);

$this->setupUtility->setConfig(
    [['design/head/demonotice', 1]],
    'default',
    0
);

$this->setupUtility->setConfig([
    ['design/head/demonotice', 1],
    ['web/cookie/cookie_httponly', 1]
]);

$this->setupUtility->setConfig([
    ['design/head/demonotice', 1], // will be set at default
    ['web/cookie/cookie_httponly', 1] // will be set at default
    ['web/cookie/cookie_path', '/', 'stores', 1], // will be set for store 1
    ['web/cookie/cookie_path', '/', 'stores', 2], // will be set for store 2
]);

$this->setupUtility->updateEmailTemplate($templateId, function($template){
    /** @var \Magento\Email\Model\BackendTemplate $template */
    $template->setTemplateText(
        file_get_contents($newTemplateContentPath)
    );
    return $template;
});