#StackBounty: #magento2 #checkout #uicomponent #plugin #custom-field Get selected country id and region name in class LayoutProcessor o…

Bounty: 50

I have a custom module app/code/Learning/FirstUnit/ and in that i have LayoutProcessor.php file in app/code/Learning/FirstUnit/Plugin.

Please see the below code in LayoutProcessor.php

<?php

namespace LearningFirstUnitPlugin;

use MagentoDirectoryHelperData as DirectoryHelper;
use MagentoDirectoryModelResourceModelCountryCollectionFactory;
use MagentoStoreModelStoreManagerInterface;
use function PHPUnitFrameworkassertIsCallable;

class LayoutProcessor
{

    public function afterProcess(
        MagentoCheckoutBlockCheckoutLayoutProcessor $subject,
        $result
    ) {
  
        //For shipping form
        $result['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['city'] = [
            'component' => 'Magento_Ui/js/form/element/select',
            'config' => [
                'customScope' => 'shippingAddress',
                'template' => 'ui/form/field',
                'elementTmpl' => 'ui/form/element/select',
                'id' => 'drop-down',
            ],
            'dataScope' => 'shippingAddress.city',
            'label' => __('City'),
            'provider' => 'checkoutProvider',
            'visible' => true,
            'validation' => [],
            'sortOrder' => 70,
            'id' => 'drop-down',
            'options' => $this->getCitiesDropdown()
        ];

        //For Billing Form
        foreach ($result['components']['checkout']['children']['steps']['children']['billing-step']['children']
                 ['payment']['children']['payments-list']['children'] as $key => $payment) {
            if (isset($payment['children']['form-fields']['children']['city'])) {
                $result['components']['checkout']['children']['steps']['children']['billing-step']['children']
                ['payment']['children']['payments-list']['children'][$key]['children']['form-fields']['children']
                ['city'] = [
                    'component' => 'Magento_Ui/js/form/element/select',
                    'config' => [
                        'customScope' => 'shippingAddress',
                        'template' => 'ui/form/field',
                        'elementTmpl' => 'ui/form/element/select',
                        'id' => 'drop-down',
                    ],
                    'label' => __('City'),
                    'provider' => 'checkoutProvider',
                    'visible' => true,
                    'validation' => [],
                    'sortOrder' => 70,
                    'id' => 'drop-down',
                    'options' => $this->getCitiesDropdown()
                ];
            }
        }

        return $result;

    }

    public function getCitiesDropdown()
    {
        
        return [
        ['value' => "test1", "label" => "Test city 1", "is_default" => true], 
        ['value' => "test2", "label" => "Test city 2", "is_default" => false],
        ['value' => "test3", "label" => "Test city 3", "is_default" => false]
        ];
    }

}

This code is for to make the city field in checkout page as dropdown.

In getCitiesDropdown function I need to get the id of user selected country and region name that user type or selected . How can I get this .

I have custom table in database, so if I get the user typed region name then I will load the corresponding city name in the dropdown form that table.

Please help.


Get this bounty!!!

#StackBounty: #git #checkout PyDriller – "Reference is not a tree"

Bounty: 50

I am trying to traverse through the commits of a repository.

I am using PyDriller to do so. I initialise the repository as a PyDriller Git repo. I then checkout the PyDriller Git repo at each commit. It works for multiple commits until I try to checkout a merge commit. I receive this error

    git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git checkout -f c9e7ca3de6d9e99cfcc1439a877465e566f452b1
  stderr: 'fatal: reference is not a tree: c9e7ca3de6d9e99cfcc1439a877465e566f452b1'

I can manually checkout this commit using the terminal so I am unsure why it does not work using my python code

The code works like this:

for commit in Repository(repo_path).traverse_commits():
    ...
    ...
    current_repo.checkout(commit_hash)

Which is confusing because this works until we hit a merge commit?


Get this bounty!!!