adminhtml – Magento admin ajax call file upload

I’m trying to make a ajax call in admin page to upload a csv file in directory then to make a stock update function.

In my PHTML:

<form method="post" enctype="multipart/form-data" id="ajaxCall" >
<input name="form_key"  type="hidden" value="<?php /* @escapeNotVerified */ echo $block->getFormKey() ?>"  />
<span class="file-uploader-button action-default">Upload CSV file:</span> <input id="image_to_upload" type="file" name="file" required />
<br/>
<input type="submit" id="import"/>
</form>
<script>

require((
    "jquery"
), function ($) {
     //your code to send ajax request here
     $.noConflict();    
    formdata = new FormData();      
    $("#image_to_upload").on("change", function() {
        alert("hello")
        var file = this.files(0);
        if (formdata) {
            formdata.append("image", file);
            $.ajax({
                url: "admin/grid/index/index",
                type: "POST",
                data: {dat:formdata,form_key: window.FORM_KEY},

                success:function(request){
                    console.log("success",request)
                },
                error:function (request, status, error) {
                    alert(request.responseText);
                }
            });
        }                       
    });   
});

</script>

When I click trigger this function I get below error.

jquery.js:10079 Uncaught TypeError: Illegal invocation

I have this script in the phtml which belongs to the same controller where I post using ajax because I have to show product update progress in the same page. In that controller I will get data like below if ajax works fine. Please note this is the previous working code in my phtml. I want to edit this code for controller standards.

<?php 
    $objectManager = MagentoFrameworkAppObjectManager::getInstance ();
    $fileSystem = $objectManager->create('MagentoFrameworkFilesystem');
    $mediaPath = $fileSystem->getDirectoryRead(MagentoFrameworkAppFilesystemDirectoryList::MEDIA)->getAbsolutePath();
    $stockRegistry = $objectManager->create('MagentoCatalogInventoryApiStockRegistryInterface');
    $product = $objectManager->get('MagentoCatalogModelProduct');
if(isset($_POST('submit'))){
    if (!file_exists($mediaPath.'csv')) {
        mkdir($mediaPath.'csv', 0777, true);
    }
    $file_type = $_FILES('file')('type'); //returns the mimetype
    $allowed = array('text/csv');
    if(!in_array($file_type, $allowed)) {?>
    <h1 class="error">Only CSV files allowed</h1>
    <tr>
        <td>Wrong format</td>
        <td>Wrong format</td>
        <td>Wrong format</td>
    </tr>
    <?php
    }else{    
    $displayFlag = 1;
    $csv =  $_FILES('file');    
    $targetdir = $mediaPath;   
    $image_name=$_FILES('file')('name');
    $temp = explode(".", $image_name);
    $newfilename = round(microtime(true)) . '.' . end($temp);
    $imagepath=$mediaPath."csv/".$image_name;
    if(move_uploaded_file($_FILES("file")("tmp_name"),$imagepath)){
        $csvFile = file($imagepath);
        $data = ();
        foreach ($csvFile as $line) {
            $data() = str_getcsv($line, ",", '"');
        }
        var_dump( count($data));
        $keys = ();
        $result = ();
        foreach($data as $key => $value){
            if($key == 0){
                $keys = $value;
            }            
        }
        foreach($data as $key => $value){
            if($key !== 0){
                $result() = array_combine($keys, $value);
            }            
        }
        foreach($result as $key => $value){
            if($product->getIdBySku($value('sku'))) {
                $stockItem = $stockRegistry->getStockItemBySku($value('sku'));
                $stockItem->setQty($value('qty'));
                $sku = $value('sku');            
                if($stockRegistry->updateStockItemBySku($sku, $stockItem)){                
                    ?>
                    <tr>
                        <td><?php echo $value('sku') ?></td>
                        <td><?php echo $value('qty') ?></td>
                        <td>Updated</td>
                    </tr>
                <?php
                }else{?>
                    <tr>
                        <td><?php echo $value('sku') ?></td>
                        <td><?php echo $value('qty') ?></td>
                        <td>Updated</td>
                    </tr>
                    <?php
                }
            }else{ ?>
                 <tr>
                        <td><?php echo $value('sku') ?></td>
                        <td><?php echo $value('qty') ?></td>
                        <td>Sku Not found</td>
                    </tr>
            <?php
            }
        }
    }
}
}
?>
</table>

magento2 – Magento 2 PHP Fatal error: Uncaught Error: Call to a member function getName() on null in

How solve this issue? Error log (PHP Fatal error: Uncaught Error: Call to a member function getName() on null in) is for line 4: $page_title = $brand->getName();

protected function _prepareLayout()
{
    $brand = $this->getCurrentBrand();
    $page_title = $brand->getName();
    $meta_description = $brand->getMetaDescription();
    $meta_keywords = $brand->getMetaKeywords();
    $this->_addBreadcrumbs();
    if($page_title){
        $this->pageConfig->getTitle()->set($page_title);   
    }
    if($meta_keywords){
        $this->pageConfig->setKeywords($meta_keywords);   
    }
    if($meta_description){
        $this->pageConfig->setDescription($meta_description);   
    }
    return parent::_prepareLayout();
}

java – unchecked call to TableRowSorter(M) as a member of the raw type TableRowSorter

He declarado una tabla para ingresar los datos de clientes pero al hacer un Clean and build del proyecto me salen unos warnings referentes al TableRowSorter.

¿Cuál es el problema de que aparezcan esos warnings?

Warnings:

Listado_clientes.java:88: warning: (unchecked) unchecked call to TableRowSorter(M) as a member of the raw type TableRowSorter
            TableRowSorter sorter = new TableRowSorter(modelo);
  where M is a type-variable:
    M extends TableModel declared in class TableRowSorter
Listado_clientes.java:89: warning: (unchecked) unchecked method invocation: method setRowSorter in class JTable is applied to given types
            tabla_clientes.setRowSorter(sorter);
  required: RowSorter<? extends TableModel>
  found: TableRowSorter
Listado_clientes.java:89: warning: (unchecked) unchecked conversion
            tabla_clientes.setRowSorter(sorter);
  required: RowSorter<? extends TableModel>
  found:    TableRowSorter
Listado_clientes.java:547: warning: (unchecked) unchecked call to setRowFilter(RowFilter<? super M,? super I>) as a member of the raw type DefaultRowSorter
        TRSFiltro.setRowFilter(RowFilter.regexFilter(textfield_buscar.getText(), columna));
  where M,I are type-variables:
    M extends Object declared in class DefaultRowSorter
    I extends Object declared in class DefaultRowSorter
Listado_clientes.java:559: warning: (unchecked) unchecked call to TableRowSorter(M) as a member of the raw type TableRowSorter
        TRSFiltro = new TableRowSorter(tabla_clientes.getModel());
  where M is a type-variable:
    M extends TableModel declared in class TableRowSorter
Listado_clientes.java:560: warning: (unchecked) unchecked method invocation: method setRowSorter in class JTable is applied to given types
        tabla_clientes.setRowSorter(TRSFiltro);
  required: RowSorter<? extends TableModel>
  found: TableRowSorter
Listado_clientes.java:560: warning: (unchecked) unchecked conversion
        tabla_clientes.setRowSorter(TRSFiltro);
  required: RowSorter<? extends TableModel>
  found:    TableRowSorter

Os muestro las líneas de los errores:

private TableRowSorter TRSFiltro;

DefaultTableModel modelo = new DefaultTableModel();
tabla_clientes.setModel(modelo);

//Ordenar las filas por la primera columna DNI.
TableRowSorter sorter = new TableRowSorter(modelo);
tabla_clientes.setRowSorter(sorter);

public void filtrar_dni() {
   int columna = 0; //Es la fila del DNI.
   TRSFiltro.setRowFilter(RowFilter.regexFilter(textfield_buscar.getText(), columna));
}

private void textfield_buscarKeyTyped(java.awt.event.KeyEvent evt) {                                          
    textfield_buscar.addKeyListener(new KeyAdapter(){
    public void keyReleased(final KeyEvent e){
       String texto = (textfield_buscar.getText());
       textfield_buscar.setText(texto);
       filtrar_dni();
    }
    });

    TRSFiltro = new TableRowSorter(tabla_clientes.getModel());
    tabla_clientes.setRowSorter(TRSFiltro);
} 

linux – Methods for tracking processing time for long running ADD INDEX call in MySQL

I’ve set off index creation on a very large table in MySQL and while I expected it to take a long time, I’m 5 days in and wondering if there’s any way to debug potential issues or simply let it run. I don’t have a precise row count but to estimate, it’s in the 100s of billions of rows and the table is ~400GB on disk. Neither memory or CPU usage appears to be overly taxed (mem ~8GB (out of 16GB total)).

The call I made from within MySQL is as follows:

alter table prices add index(dataDate, ticker, expDate, type), add index(s
ymbol), algorithm=inplace, lock=none;

Running show processlist from within a different MySQL instance shows the call with State ‘altering table’ so the call doesn’t appear blocked. Anything else I can check to gauge progress?

For reference I’m working with MySQL 8 and within Ubuntu 18.04

Sharepoint Online | How To Properly Call Javascript and CSS files within an ASPX page?

Sorry if this could already have been answered but I am new to Sharepoint Online.

With previous versions of Sharepoint, this has been working fine for me until now.

  1. Upload an HTML, CSS and JS files within any document repository in Sharepoint
  2. Call the CSS and JS files using traditional src=”http://sharepoint.stackexchange.com/RelativePathToTheCSSandJSFiles”

With Sharepoint online, this seems to no longer work. For testing purposes, what I do now is this:

  1. Upload .ASPX file within the default Document folder of a site collection I created
  2. Upload the CSS and JS files within the default Style Library Folder

enter image description here

  1. Called the CSS file using the following script

enter image description here

  1. Called the JS file using the following script

enter image description here

Am I doing this the right way? Please help.

unity – How to call StartCourotine in abstract class?

Bellow is my code. I have an abstract class and a inheriting class. This keeps giving me an NullReferenceException, on the StartCoroutine(WaitForTime) when Activate() is called on a InheritedClass instance. I can’t figure it out.

public abstract class AbstractClass : MonoBehaviour
{
abstract protected string iD { get; }
abstract protected int CooldownSeconds { get;  }

protected bool IsInCooldown { get; set; }


public void Activate()
{
    if (!IsInCooldown)
    {
        TurnOn();
        StartCooldown();
    }
}

protected abstract void TurnOn();

public void StartCooldown()
{
    IsInCooldown = true;
    StartCoroutine("WaitForTime");
}

protected IEnumerator WaitForTime()
{

    yield return new WaitForSeconds(CooldownSeconds);
    IsInCooldown = false;
}



}

public class InheretingClass : AbstractClass
{
    protected override int CooldownSeconds { get => 30;}

protected override string collD => "Cool";

protected override void TurnOn()
{
    Debug.Log( iD + " Activated");
}
}

magento2 – Uncaught Error: Call to undefined method – Magento 2.3.2 – PicPay

(26-May-2020 21:47:11 UTC) PHP Fatal error: Uncaught Error: Call to undefined method MagentoPaymentGatewayDataOrderOrderAdapter::getCustomerIsGuest() in /home/extre146/public_html/atividades/app/code/Picpay/Payment/Helper/Data.php:593
Stack trace:

lines 593 – 599

   if(!$order->getCustomerIsGuest()){
        $customerId = $order->getCustomerId();
        $customer = $this->customerRepositoryInterface->getById($customerId);
        if ($customer && $customer->getId()) {
            $taxvat = $customer->getTaxvat();
        }
    }

magento2.3 – Magento 2.3.5 – Call extended order model function in email template

i want to know how model functions work in email templates.

In the template original functions are called like

{{var order.getEmailCustomerNote()

I extended the order model, so i added a function getCustomerNameFormal()

When debug the function prepareTemplate in the class Model/Order/Email/Sender/OrderSender.php, the order object is extended and i can call my new function.
$order->getCustomerNameFormal()
The templateVars order has this function, too.
But when i try to call this in the email template, i dont get a result.
order.getCustomerNameFormal()
although tried
$order.getCustomerNameFormal()
but nothing works.

Is it possible to get this working? I have a solution with observer, but there i have to add the variable to each email sender. I want to get the function global on the order object.

Can it be that in email templates i can only call the functions specified in the OrderInterface?

Hope someone can help me with this problem.

Best Regards,
Andreas