Magento 1.9 removes unused product images

I've tried to use this bash script to remove any unused product images, but unfortunately, the images used are also removed.

database=name
for path in `find . -type f $1`; do 
    extension="${path##*.}"
    if (( "$extension" != "jpg" )) && (( $extension != "jpeg" )) && (( $extension != "png" )) && (( $extension != "gif" )) && (( $extension != "bmp" )); then
        echo "extension: $extension $path"
        continue
    fi 
    delpath=${path:2}
    path=${path:1}
    query="SELECT value FROM catalog_product_entity_media_gallery WHERE value='$path';"
    sqlpath=`mysql --defaults-extra-file=mysqlconfig.cnf --database="$database" -s -N --execute="$query"`;
    if (( "$sqlpath" )); then
        echo  -n ""
    else
        name=$(basename -- "$path")
        find . -type f -name "$name" -delete -print
    fi
done   

The script recursively goes through the product images and deletes them if they are not in the catalog_product_entity_media_gallery table. If they are not there, they will not be used.
Is the query correct to find unused product images?

magento2.3 – How do I add a custom action to an XML button in a listing element in ui_component? Magento 2

I have a custom module with a view folder. This view folder contains a ui_component folder with an XML file called mobileplans_listing_xml. This XML file creates a listing element as a parent tag.
I'm trying to add another button named "Refresh Dids" to this list item and call my own custom action for clicking the button. On this page, there is a Add Virtual Number button, which redirects to the new controller.
For some reason, adding a button to this XML adds a standard click HTML event handler. I want to create my own click event / my own click action and not use the default setting. How do I proceed?

Here is the XML file




    
        mobileplans_virtualnumbers_listing.mobileplans_virtualnumbers_listing_data_source
        mobileplans_virtualnumbers_listing.mobileplans_virtualnumbers_listing_data_source
    
    virtualnumbers_columns
    
        
            add
            Add Virtual Numbers
            primary
            */*/new
        
        
            add
            Refresh Dids
        
    
  

    
        VirtualnumbersGridDataProvider
        mobileplans_virtualnumbers_listing_data_source
        id
        id
        
            
                Magento_Ui/js/grid/provider
                
                
                    id
                
            
        
    


    
        false
    
    
    
    
    
        
            
                column
            
        
        
            
                
                    
                
            
        
    
    
        
            
                
                    Are you sure you want to delete selected items?
                    Delete items
                
                
                delete
                
            
        
    
    


    
        
            
                
                false
            
            id
            true
            mobileplans_virtualnumbers_listing.mobileplans_virtualnumbers_listing.virtualnumbers_columns.ids
        
        
            
                mobileplans_virtualnumbers_listing.mobileplans_virtualnumbers_listing.virtualnumbers_columns_editor
                startEdit
                
                    ${ $.$data.rowIndex }
                    true
                
            
        
    
    
        
            id
            false
            55
        
    
    
        
            textRange
            
            asc
        
    
    
        
            text
            
                
                    true
                
                text
            
            
        
    
    
        
            text
            
                
                    true
                
                text
            
            
        
    
    
        
            text
            
                
                    true
                
                text
            
            
        
    
    
        
            text
            
                
                    true
                
                text
            
            
        
    
    
        
            text
            
                
                    true
                
                text
            
            
        
    
    
        
            MagentoConfigModelConfigSourceYesno
            
                select
                Is External
                Magento_Ui/js/grid/columns/select
                select
                
                    select
                
            
        
    
    
        
            dateRange
            date
            
        
    
    
        
            dateRange
            date
            
        
    
    
        
            id
            false
            107
        
    


magento2.3 – Magento 2.3.1 :: Orphan attribute records

Recently we had a problem with the number of files in the pub/media/product/cache Folder that causes us to run out of inodes.

In our research, we found many duplicate images in the folder. Hoping to remove them, we used this extension to remove only a few images.

Since there were many images that did not belong to products, we found it strange that so few pictures were removed. Here the real problem (or part of it) was discovered.

In that catalog_product_entity_varchar There are references to these images in the table, but the entity_id for these records does not match entities in the table catalog_product_entity,

I think that's why the extension mentioned above did not delete the duplicates because they were considered to be used by these defunct entities.

So the real question is why these records were not removed when the product was deleted. And why were the pictures also left on the server?

For now, I think I'll run a query to remove the orphaned records from the attribute table.

delete from 
    catalog_product_entity_varchar att 
where 
    (select 
         count(*) 
    from 
        catalog_product_entity 
    where entity_id=att.entity_id) = 0

So in summary:

  • Why are the attribute records removed when the entity is deleted?
  • Why do the product images stay behind when a product is deleted?
  • Is it safe to run the above query to delete these records?

magento2.3 – Magento 2 Daily Deal

Daily Deal applies the discount value to the product price. However, I would like the rebate applied to the price defined for each customer group.

Enter image description here

public function getProductPrice($sku)
    {
        $productcollection=$this->productFactory->create()->getCollection();
        $productcollection->addAttributeToSelect('*');
        $productcollection->addAttributeToFilter('sku', ('eq'=>$sku));
        $productcollection->addAttributeToFilter('type_id', ('neq'=>'bundle'));
        if ($productcollection->getSize() ==1 && $productcollection->getFirstItem()->getTypeId() !="grouped") {
            return $productcollection->getFirstItem()->getFinalPrice();
        } else {
            return 1;
        }
    }

Customer groups:

Enter image description here

magento2 – Magento 2 extension: BlackFriday Offers?

There are a variety of providers offering massive discounts on Magento 2 Extensions on Black Friday. LandOfCoder is truly one of the most generous providers offering 50% DISCOUNT on ALL available items. Here are some useful links to enjoy this valuable event from now on:

Check the detail: 50% DISCOUNT ON THE WHOLE BASKET | Magento 2 Black Holiday Code 2019

LandOfCoder official websites provide more information about Magento 2 Extensions: Landofcoder.com

Do good business with this top-selling product!

Magento 2 BlackFriday Offers 2019

newsletter – Is there anyone who wonders how much has been improved in magento 2.3.3?

I have this question for so long guys, only if someone can summarize it briefly. Oh yes, I've been working on a post for so long and it would mean that the world pops by and reads a bit. https://www.mage-world.com/blog/magento-2-3-3.html Thanks, guys. This post can help some people to get more information ^^ Have fun ^^

magento2.3 – How can I hijack the click event of a button with my own Ajax Get function? Magento 2

I want to add a new button to an existing admin page.
I want to call an Ajax Get () function that clicks this button.
I've created a main.js script file to load on this page because when I create a console.log, I get the code here.
Although there is another script file that "hijacks" the click of this button.
Rather than triggering my Ajax function from main.js, another JS function is triggered by a require_js.phtml file.

The code in the require_js.phtml file:



This is the JS Ajax function that I want to trigger from main.js, but which is "hijacked". Although console.log ("jivet click"); is logged.

$("#jivet").click(function() {
    console.log("jivet click");
    $.get(
        "https://online.jivet.com/api/index.aspx?action=GetAllDIDs",
        function(data) {
            console.log("page content: " + data);
        }
    );
});