magento 1.9 – Fatal error: Call to a member function setData() on boolean in core/Mage/Adminhtml/Block/Widget/Form/Container.php on line 144

Good evening guys!

I am almost giving up on this error that i am getting with a new module.

Fatal error: Call to a member function setData() on boolean in /var/www/public_html/app/code/core/Mage/Adminhtml/Block/Widget/Form/Container.php on line 144

These line refers to this part:

public function getFormHtml()
{
    $this->getChild('form')->setData('action', $this->getSaveUrl());
    return $this->getChildHtml('form');
}

I have the following structure:

Company_Module_Block_Adminhtml_Campaign_Edit_Tabs > Company_Module_Block_Adminhtml_Campaign_Edit_Tab_Form > Company_Module_Block_Adminhtml_Campaign_Edit_Form

Ok i have Xdebug running on this project and everything is being called except this one :

Company_Module_Block_Adminhtml_Campaign_Edit_Form

My Edit.php is everything ok too:

    parent::__construct();
    $this->_blockGroup = 'company_module';
    $this->_controller = 'adminhtml_module';

I’ve being trying to resolve this error for days, searched every place but still with no answer 🙁

magento2 – Magento 2 – How to modify the URL of products of this widget?

I have this widget.

{{widget type="MagentoCatalogWidgetBlockProductProductsList" show_pager="0" products_count="10" template="Magento_CatalogWidget::product/widget/content/grid.phtml" conditions_encoded="^[`1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Combine`,`aggregator`:`all`,`value`:`1`,`new_child`:``^],`1--1`:^[`type`:`Magento||CatalogWidget||Model||Rule||Condition||Product`,`attribute`:`category_ids`,`operator`:`==`,`value`:`677`^]^]"}}

Is there any way to modify the URL of the products listed here?

magento2 – how to add custom user agent with android in magento 2?

You can try this.

<?php
//This will identify user agent mobile or not
               if(preg_match('/(android|bbd+|meego).+mobile|avantgo|bada/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)/|plucker|pocket|psp|series(4|6)0|symbian|treo|up.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i',$_SERVER('HTTP_USER_AGENT'))||preg_match('/1207|6310|6590|3gso|4thp|50(1-6)i|770s|802s|a wa|abac|ac(er|oo|s-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw-(n|u)|c55/|capi|ccwa|cdm-|cell|chtm|cldc|cmd-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc-s|devi|dica|dmob|do(c|p)o|ds(12|-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez((4-7)0|os|wa|ze)|fetc|fly(-|_)|g1 u|g560|gene|gf-5|g-mo|go(.w|od)|gr(ad|un)|haie|hcit|hd-(m|p|t)|hei-|hi(pt|ta)|hp( i|ip)|hs-c|ht(c(-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i-(20|go|ma)|i230|iac( |-|/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |/)|klon|kpt |kwc-|kyo(c|k)|le(no|xi)|lg( g|/(k|l|u)|50|54|-(a-w))|libw|lynx|m1-w|m3ga|m50/|ma(te|ui|xo)|mc(01|21|ca)|m-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10(0-2)|n20(2-3)|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|-((1-8)|c))|phil|pire|pl(ay|uc)|pn-2|po(ck|rt|se)|prox|psio|pt-g|qa-a|qc(07|12|21|32|60|-(2-7)|i-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55/|sa(ge|ma|mm|ms|ny|va)|sc(01|h-|oo|p-)|sdk/|se(c(-|0|1)|47|mc|nd|ri)|sgh-|shar|sie(-|m)|sk-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h-|v-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl-|tdg-|tel(i|m)|tim-|t-mo|to(pl|sh)|ts(70|m-|m3|m5)|tx-9|up(.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5(0-3)|-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas-|your|zeto|zte-/i',substr($_SERVER('HTTP_USER_AGENT'),0,4))) {
        
echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Vendor_Module::your-template-file.phtml")->toHtml();
        
}
?>

magento2 – Magento 2 setup:di:compile not work

When i try to start command setup:di:compile i see this error:

enter image description here

and this is the file FileClassScanner.php:

<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

namespace MagentoSetupModuleDiCodeReader;

/**
 * Class FileClassScanner
 *
 * @package MagentoSetupModuleDiCodeReader
 */
class FileClassScanner
{
    private const NAMESPACE_TOKENS = (
        T_WHITESPACE => true,
        T_STRING => true,
        T_NS_SEPARATOR => true
    );

    private const ALLOWED_OPEN_BRACES_TOKENS = (
        T_CURLY_OPEN               => true,
        T_DOLLAR_OPEN_CURLY_BRACES => true,
        T_STRING_VARNAME           => true);

    /**
     * The filename of the file to introspect
     *
     * @var string
     */
    private $filename;

    /**
     * The list of classes found in the file.
     *
     * @var bool
     */
    private $classNames = false;

    /**
     * @var array
     */
    private $tokens;

    /**
     * Constructor for the file class scanner.  Requires the filename
     *
     * @param string $filename
     */
    public function __construct($filename)
    {
        // phpcs:ignore
        $filename = realpath($filename);
        // phpcs:ignore
        if (!file_exists($filename) || !is_file($filename)) {
            throw new InvalidFileException(
                sprintf(
                    'The file "%s" does not exist or is not a file',
                    $filename
                )
            );
        }
        $this->filename = $filename;
    }

    /**
     * Retrieves the contents of a file.  Mostly here for Mock injection
     *
     * @return string
     */
    public function getFileContents()
    {
        // phpcs:ignore
        return file_get_contents($this->filename);
    }

    /**
     * Extracts the fully qualified class name from a file.
     *
     * It only searches for the first match and stops looking as soon as it enters the class definition itself.
     *
     * Warnings are suppressed for this method due to a micro-optimization that only really shows up when this logic
     * is called several millions of times, which can happen quite easily with even moderately sized codebases.
     *
     * @SuppressWarnings(PHPMD.CyclomaticComplexity)
     * @SuppressWarnings(PHPMD.NPathComplexity)
     * @return array
     */
    private function extract()
    {
        $classes = ();
        $namespaceParts = ();
        $class = '';
        $triggerClass = false;
        $triggerNamespace = false;
        $braceLevel = 0;
        $bracedNamespace = false;

        // phpcs:ignore
        $this->tokens = token_get_all($this->getFileContents());
        foreach ($this->tokens as $index => $token) {
            $tokenIsArray = is_array($token);
            // Is either a literal brace or an interpolated brace with a variable
            if ($token === '{' || ($tokenIsArray && isset(self::ALLOWED_OPEN_BRACES_TOKENS($token(0))))) {
                $braceLevel++;
            } elseif ($token === '}') {
                $braceLevel--;
            }
            // The namespace keyword was found in the last loop
            if ($triggerNamespace) {
                // A string ; or a discovered namespace that looks like "namespace name { }"
                if (!$tokenIsArray || ($namespaceParts && $token(0) === T_WHITESPACE)) {
                    $triggerNamespace = false;
                    $namespaceParts() = '\';
                    continue;
                }
                $namespaceParts() = $token(1);

            // The class keyword was found in the last loop
            } elseif ($triggerClass && $token(0) === T_STRING) {
                $triggerClass = false;
                $class = $token(1);
            }

            switch ($token(0)) {
                case T_NAMESPACE:
                    // Current loop contains the namespace keyword.  Between this and the semicolon is the namespace
                    $triggerNamespace = true;
                    $namespaceParts = ();
                    $bracedNamespace = $this->isBracedNamespace($index);
                    break;
                case T_CLASS:
                    // Current loop contains the class keyword.  Next loop will have the class name itself.
                    if ($braceLevel == 0 || ($bracedNamespace && $braceLevel == 1)) {
                        $triggerClass = true;
                    }
                    break;
            }

            // We have a class name, let's concatenate and store it!
            if ($class !== '') {
                $fqClassName = trim(join('', $namespaceParts)) . trim($class);
                $classes() = $fqClassName;
                $class = '';
            }
        }
        return $classes;
    }

    /**
     * Looks forward from the current index to determine if the namespace is nested in {} or terminated with ;
     *
     * @param integer $index
     * @return bool
     */
    private function isBracedNamespace($index)
    {
        $len = count($this->tokens);
        while ($index++ < $len) {
            if (!is_array($this->tokens($index))) {
                if ($this->tokens($index) === ';') {
                    return false;
                } elseif ($this->tokens($index) === '{') {
                    return true;
                }
                continue;
            }

            if (!isset(self::NAMESPACE_TOKENS($this->tokens($index)(0)))) {
                throw new InvalidFileException('Namespace not defined properly');
            }
        }
        throw new InvalidFileException('Could not find namespace termination');
    }

    /**
     * Retrieves the first class found in a class file.
     *
     * The return value is in an array format so it retains the same usage as the FileScanner.
     *
     * @return array
     */
    public function getClassNames()
    {
        if ($this->classNames === false) {
            $this->classNames = $this->extract();
        }
        return $this->classNames;
    }
}

I tried to search but i have not found anything abaout this issue.
How can i do?

Thanks

Disable fronend in Magento 2 for a specific module for using only the Admin and the API routes

How to disable the fronend in Magento 2 for a specific module so I can use the Adminpanel and the API routes.

magento2 – Magento 2.4.1 admin tfa configuration page is blank

I just migrated from Magento 2.3.4 to 2.4.1 , after i logged in from the backend i was redirected to TFA configuration page, but it shows blank container like this:

enter image description here

i already ran these commands below, but nothing changes

bin/magento config:set twofactorauth/general/force_providers google
bin/magento config:set twofactorauth/google/otp_window 60
bin/magento in:rei
bin/magento c:c 

Magento – PayPal express checkout button missing in Shopping cart

Anyone else getting PayPal express checkout button in shopping cart missing?

enter image description here

From older posts It looks like It might be from the server being down?

Anyway, when I got to : fpdbs.paypal.com I can’t reach the website.

The button image source is : https://fpdbs.paypal.com/dynamicimageweb?cmd=_dynamic-image&buttontype=ecshortcut&locale=en_GB&ordertotal=#####&pal=########

And that fails too.

Anyone else?

magento2 – Magento 2 API creat product width multiple images

I would like to create a product with several images via API.

It also works but he only reads one picture.
The others pictures only show the default thumbnail in the Magento backend.

enter image description here

He fetches the images via foreach:

foreach($_POST('image') as $key => $value) {

  $path_parts = pathinfo($value);

  $image() = array(
      'id' => $key,
      'media_type' => 'image',
      'label' => 'Product Image '.$key,
      'position' => $key,
      'disabled' => 'false',
      'types' => array('image','small_image','thumbnail'),
      'file' => $path_parts('filename').'.'.$path_parts('extension'),
      'content' => array(
        "base64_encoded_data" => base64_encode(file_get_contents($value)),
        "type" => "image/jpeg",
        "name" => $path_parts('filename').'.'.$path_parts('extension')
      )
    );
}

and then output in the post

$post ='{
  "product": {
    "sku": "DS12342134",
    "name": "Test",
    "attribute_set_id": 4,
    "price": 25,
    "status": 1,
    "visibility": 1,
    "type_id": "simple",
    "weight": "0.5",
    "media_gallery_entries":
      '.json_encode($image).'
    ,
  }
}';

can someone help?

template – Magento 2 Knockout bind on ajax response

I am going crazy with knockout on Magento 2, I am new to knockout and I cannot understand what I am doing wrong. I know there are some related questions posted there but each one is different from what I need. I checked all questions posted before, all links on google, still cannot understand why is not working.

I am trying to retrieve the shipping data on product page on Magento 2 and append them with foreach inside template.

That is what I have until now:

calculate.js

define((
    'jquery',
    'mage/translate',
    'mage/storage',
    'mageUtils',
    'uiComponent',
    'ko'
), function (
    $,
    $t,
    storage,
    utils,
    Component,
    ko
) {

    return Component.extend({

        defaults: {
            carrier: null
        },
        initialize: function (config) {
            var self = this;
            this._super();
            this.carrier = ko.observable();
            this.carrier_f(this.sku);
            return this;
        },
        carrier_f: function (sku) {
            var address;
            var postcode;
            var myViewModel;
            var carrier_view = {};

            var serviceUrlCreate, serviceUrl, payload;
            /**
             * Save  values .
             */
            serviceUrl = '/rest/V1/working_function/' + sku;
            payload = JSON.stringify({
                    address: {
                        'city': '',
                        'region_id': '569',
                        'country_id': 'US',
                        'postcode': '',
                    }
                }
            );
            storage.post(
                serviceUrl,
                payload
            ).done(function (response) {
                this.carrier = ko.observable();

                var carrier_view = {
                    'carrier': this.response
                };


                ko.cleanNode($('#shipping_results')(0));
                ko.applyBindings(carrier_view, $('#shipping_results')(0));

                console.log(response);

            }).fail(function (response) {
                console.log(response);
            });

        },

        checkShipping: function () {

            console.log(this.sku);
            
            this.carrier_f(this.sku);
        }
        
    });
    
});

form.phtml

<div data-bind="scope: 'shipping_estimate'">
    <ul id="shipping_results" data-bind="foreach: carrier">
        <li>
            <span data-bind="text: carrier_title"></span>
        </li>
    </ul>
</div>
    <button data-bind="click: checkShipping" class="btn-estimate">Check</button>

    <script type="text/x-magento-init">
                                       {
                                          "*": {
                                                  "Magento_Ui/js/core/app": {
                                                         "components": {
                                                             "shipping_estimate": {
                                                                  "component": "Vendor_Name/js/calculate",
                                                                  "sku": "<?= $block->getProduct()->getSku(); ?>"
                                                              }
                                                         }
                                                   }
                                             }
                                        }                                  
    </script>

Ajax Response is like that:

enter image description here

So basically I need to get results on page load and also when click the Check Button (I will add some textbox after), but now there are not results inside, just empty response.

I tried everything, but still not found a solution, the only thing seems working is to change the scope to “anything-else”, then the foreach is working, but the click event is not called.

If anyone has the patience to explain me what I am doing wrong I would really appreciate it. Thank you