sharepoint online – Programatically Deploy List Item Layout

Suppose we created a list with a custom list form layout. Now, I want to move this list to a different SharePoint tenant/site. How do I programmatically apply the custom form laout?

enter image description here

More details
I am using SharePoint PnP Provisioning templates to export and import lists. Unfortunately, it does not seem that the PnP Provisining template contains list item form’s laoyout.

Example of the Header JSON that I am trying to deploy programmatically:

    "elmType": "div",
    "attributes": {
        "class": "ms-borderColor-neutralTertiary"
    "style": {
        "width": "99%",
        "border-top-width": "0px",
        "border-bottom-width": "1px",
        "border-left-width": "0px",
        "border-right-width": "0px",
        "border-style": "solid",
        "margin-bottom": "16px"
    "children": [
            "elmType": "div",
            "style": {
                "display": "flex",
                "box-sizing": "border-box",
                "align-items": "center"
            "children": [
                    "elmType": "div",
                    "attributes": {
                        "iconName": "Mail",
                        "class": "ms-fontSize-42 ms-fontWeight-regular ms-fontColor-themePrimary",
                        "title": "Details"
                    "style": {
                        "flex": "none",
                        "padding": "0px",
                        "padding-left": "0px",
                        "height": "36px"
            "elmType": "div",
            "attributes": {
                "class": "ms-fontColor-neutralSecondary ms-fontWeight-bold ms-fontSize-24"
            "style": {
                "box-sizing": "border-box",
                "width": "100%",
                "text-align": "left",
                "padding": "21px 12px",
                "overflow": "hidden"
            "children": [
                    "elmType": "div",
                    "txtContent": "=' ' + [$Title]"

Is there a way to apply these JSON customizations using PowerShell PnP?

content staging – How to delete/unschedule scheduled updates for product programatically in Magento 2 commerce edition?

I have added a scheduled update for a product as shown below

enter image description here

Now I want to delete this schedule programatically. How to achieve that?

I see the product staging class MagentoCatalogStagingApiProductStagingInterface which has a function unschedule($product, $version)

Where I can get the information about the version of a specific product which needs to be passed to this function?

import – Magento2: Importing additional images programatically – PHP error

I am trying to set up a script to import additional images for products programatically, from the var/import/images folder. I am running it on the command line, via PuTTY. The following code works and shows me the product name but once I uncomment the 2 lines starting with $product it fails without showing any error. Error log says

PHP Parse error: syntax error, unexpected ‘ ‘ (T_STRING) in /home/owlbarnradesyste/public_html/testcustomer.php on line 28 which is the $product > save(); line.

    ini_set('display_errors', 1);
    ini_set('display_startup_errors', 1);
    ini_set('memory_limit', '5G');
    use MagentoFrameworkAppBootstrap;
    require 'app/bootstrap.php';
    $bootstrap = Bootstrap::create(BP, $_SERVER);
    $objectManager = $bootstrap->getObjectManager();
    $state = $objectManager->get('MagentoFrameworkAppState');
    try {
        $product = $objectManager->get('MagentoCatalogModelProduct')->load(17);
        echo $product->getName();
        //$product->addImageToMediaGallery('var/import/images/111217.jpg', array('image', 'small_image', 'thumbnail'), true, false);
        catch (Exception $e) {
            echo $e->getMessage();

8 – Set “select” field on a node programatically

I am creating nodes programmatically on a specific content type. The content type has a “select field” that I am trying to set value with and cannot do it. Below is my code:

 $node = Drupal::entityTypeManager()->getStorage('node')->create(array(
      'type'  => 'level3',
      'title' => $file_name,
      field_level2_title => (
        'value' => 'Assessment'
      field_level3_title => $file_name,
      field_level3_readmore => (
        'uri' => $file_uri,
        'title' => $file_name

The select field name is “field_level2_title and I am unable to assign this. Any help?

Avoid sending email (content moderation) when node updated programatically

I have a csv import function which also will have to update the "moderation_state" field.
Once csv import is ran, email will be triggered by content_moderation module.
Is there a way to disable this when updating nodes programatically?

module – Magento 2.4: Create Order Programatically with custom Order ID

module – Magento 2.4: Create Order Programatically with custom Order ID – Magento Stack Exchange

magento2 – Multiselect Attribute created through module can’t be set programatically

I am on a Magento 2.1 installation using a Venus Theme Module called Brands 2.0.

The module creates a product_brand multi select attribute with the following code:

$eavSetup = $this->eavSetupFactory->create(('setup' => $setup));
        $data = array(
            'group' => 'General',
            'type' => 'varchar',
            'input' => 'multiselect',
            'default' => 1,
            'label' => 'Product Brand',
            'backend' => 'MagentoEavModelEntityAttributeBackendArrayBackend',
            'frontend' => '',
            'source' => 'VesBrandModelBrandlist',
            'visible' => 1,
            'required' => 1,
            'user_defined' => 1,
            'used_for_price_rules' => 1,
            'position' => 2,
            'unique' => 0,
            'default' => '',
            'sort_order' => 100,
            'is_global' => MagentoCatalogModelResourceModelEavAttribute::SCOPE_STORE,
            'is_required' => 0,
            'is_configurable' => 1,
            'is_searchable' => 0,
            'is_visible_in_advanced_search' => 0,
            'is_comparable' => 0,
            'is_filterable' => 0,
            'is_filterable_in_search' => 1,
            'is_used_for_promo_rules' => 1,
            'is_html_allowed_on_front' => 0,
            'is_visible_on_front' => 1,
            'used_in_product_listing' => 1,
            'used_for_sort_by' => 0,

Now we are trying to add products through an API, and everything is working fine except for setting this product_brand attribute. When using:

$product->setData('product_brand', $authCSV);

where $authCSV is a CSV list of option IDs. This works for other multi selects but not for product_brand. No errors are thrown but the attribute does not get saved along with the rest of them.

Any help would be appreciated.

How to set default root category on a store while creating it programatically?

I want to set a category on the new stores I’m creating, but could not find any appropriate method.

    public function  createStore()
        // load default website
        $defaultWebId = $this->defaultWebsite->load(self::DEFAULT_WEB_ID);

        // create german store
        $germanStore = $this->storeFactory->create();

        // create english store
        $englishStore = $this->storeFactory->create();

I want to set a “default root category” on both of these stores. By default root category, I mean this: enter image description here
Any kind of help would be appreciated


public function createStores()
        // load default website
        $defaultWebId = $this->defaultWebsite->load(self::DEFAULT_WEB_ID);

        // create english group
        $englishGroup = $this->groupFactory->create();
        // create german group 
        $germanGroup = $this->groupFactory->create();
        // create german store view
        $germanStore = $this->storeFactory->create();
        // create english store view
        $englishStore = $this->storeFactory->create();
        try {
        catch (LocalizedException) {

entities – How to alter entity -> bundle ->add form with custom form mode programatically Drupal 8

I have created a custom entity type called custom_enitity and new bundle scores, using UI. Also got custom form display called score to add score via custom route. I keep getting the following error message.

DrupalCoreEntityEntityStorageException: Missing bundle for entity
type custom_entity in
DrupalCoreEntityContentEntityStorageBase->doCreate() (line 108 of


  path: '/entry/{entry_id}/score'
    _entity_form: custom_entity.score
    _role: 'administrator+judge'
        type: entity:entry

In my folder I have this structure:


and the name of the class in the file is

class CustomEntityScoreForm extends ContentEntityForm

How do I add bundle (scores) to the routing file, or what am I missing here?

8 – How to alter the parameters in the file programatically?

I need to modify the filter_protocols parameter inside the file programmatically to add a new protocol. I know how to alter a service but I don’t find any information about how to alter a parameter.

    gc_probability: 1
    gc_divisor: 100
    gc_maxlifetime: 200000
    cookie_lifetime: 2000000
    debug: false
    auto_reload: null
    cache: true
    required_cache_contexts: ['languages:language_interface', 'theme', 'user.permissions']
      max-age: 0
      contexts: ['session', 'user']
      tags: []
    default: keyvalue.database
  http.response.debug_cacheability_headers: false
    default: keyvalue.expirable.database
    - http
    - https
    - ftp
    - news
    - nntp
    - tel
    - telnet
    - mailto
    - irc
    - ssh
    - sftp
    - webcal
    - rtsp

I know how to do this by copying the services.yml file inside the sites/default folder but at this time I need to do this programmatically.

Any idea about how to do it?

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies 5000 Private Proxies - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies New Proxy Lists Every Day Buy Cheap Private Proxies; Best Quality USA Private Proxies