PHP code example of panakour / shopware-dal-toolkit
1. Go to this page and download the library: Download panakour/shopware-dal-toolkit 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/ */
panakour / shopware-dal-toolkit example snippets
use Panakour\ShopwareDALToolkit\Dal;
// Create or retrieve the Dal service from the container
$dal = $container->get(Dal::class);
$currency = $dal->getCurrencyByIsoCode($context, 'EUR');
// Create a tax
$taxName = 'Custom Tax 19%';
$taxRate = 19.0;
$dal->createTax($context, $taxName, $taxRate);
// Create or retrieve a category
$categoryName = 'My Custom Category';
$categoryId = $dal->firstOrCreateCategory($context, $categoryName);
echo $categoryId; // newly generated or existing ID
// Create or retrieve a manufacturer
$manufacturerName = 'My Manufacturer';
$manufacturerId = $dal->firstOrCreateManufacturer($context, $manufacturerName);
echo $manufacturerId; // newly generated or existing ID
use Panakour\ShopwareDALToolkit\MediaServiceHelper;
// Retrieve the MediaServiceHelper from the container
$mediaHelper = $container->get(MediaServiceHelper::class);
// Assign media from a list of URLs and/or base64-encoded images
$images = [
'https://placehold.co/100x110',
'https://placehold.co/300x300',
'data:image/png;base64,' . base64_encode($myRawPngContents),
];
$results = $mediaHelper->assignMedia($context, $images);
// Each item in $results has a 'mediaId' key
foreach ($results as $ref) {
echo $ref['mediaId']; // Newly created media ID
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.