magento2 – I have used Magento 2.3.3 (EE) + Infinit Theme, but I have received the following error information: How should I fix this? Many thanks

I have used Magento 2.3.3 (EE) + Infinit Theme, but I have received the following error information: How should I fix this? Many thanks

> Fatal error: Uncaught TypeError: Argument 2 passed to
> MagentoPageBuilderPluginCatalogBlockProductProductsListPlugin::afterCreateCollection()
> must be an instance of
> MagentoCatalogModelResourceModelProductCollection, null given,
> called in
> /data/wwwroot/dev.magecn.com/vendor/magento/framework/Interception/Interceptor.php
> on line 146 and defined in
> /data/wwwroot/dev.magecn.com/vendor/magento/module-page-builder/Plugin/Catalog/Block/Product/ProductsListPlugin.php:41
> Stack trace: #0
> /data/wwwroot/dev.magecn.com/vendor/magento/framework/Interception/Interceptor.php(146):
> MagentoPageBuilderPluginCatalogBlockProductProductsListPlugin->afterCreateCollection(Object(CodazonProductFilterBlockProductProductsListInterceptor),
> NULL) #1
> /data/wwwroot/dev.magecn.com/vendor/magento/framework/Interception/Interceptor.php(153):
> CodazonProductFilterBlockProductProductsListInterceptor->MagentoFrameworkInterception{closure}()
> #2 /data/wwwroot/dev.magecn.com/generated/code/Codazon/ProductFilter/Block/Product/Products
> in
> /data/wwwroot/dev.magecn.com/vendor/magento/module-page-builder/Plugin/Catalog/Block/Product/ProductsListPlugin.php
> on line 41

The Codazon / ProductFilter / Block / Product / Products.php as follows:

productCollectionFactory = $productCollectionFactory;
        $this->bestSellerCollectionFactory = $bestSellerCollectionFactory;
        $this->catalogProductVisibility = $catalogProductVisibility;
        $this->httpContext = $httpContext;
        $this->sqlBuilder = $sqlBuilder;
        $this->rule = $rule;
        $this->urlHelper = $urlHelper;
        $this->conditionsHelper = $conditionsHelper;
        $this->imageHelperFactory = $imageHelperFactory;
        $this->customImageBuilderFactory = $customImageBuilderFactory;
        $this->objectManager = MagentoFrameworkAppObjectManager::getInstance();
        $this->_listProduct = $this->objectManager->get('MagentoCatalogBlockProductListProduct');

        parent::__construct(
            $context,
            $productCollectionFactory,
            $catalogProductVisibility,
            $httpContext,
            $sqlBuilder,
            $rule,
            $conditionsHelper,
            $data
        );
    }

    public function getCacheKeyInfo()
    {
        if (!$this->hasData('cache_key_info')) {
            $cacheKeyInfo = (
                'PRODUCT_FILTER_WIDGET',
                $this->_storeManager->getStore()->getId(),
                $this->_storeManager->getStore()->getCurrentCurrency()->getCode(),
                $this->httpContext->getValue(MagentoCustomerModelContext::CONTEXT_GROUP),
                intval($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1)),
                $this->objectManager->get('MagentoFrameworkDataFormFormKey')->getFormKey(),
                $this->getData()
            );
            $this->setData('cache_key_info', (md5(json_encode($cacheKeyInfo))));
        }
        return $this->getData('cache_key_info');
    }

    public function getAddToCartUrl($product, $additional = ())
    {
        return $this->_cartHelper->getAddUrl($product, $additional);
    }

    public function getProductListBlock()
    {
        return $this->objectManager->get('MagentoCatalogBlockProductListProduct');
    }

    public function getAddToCartPostParams(MagentoCatalogModelProduct $product): array
    {
        $url =  $this->_listProduct->getAddToCartUrl($product);
        return (
            'action' => $url,
            'data' => (
                'product' => $product->getEntityId(),
                MagentoFrameworkAppActionInterface::PARAM_NAME_URL_ENCODED =>
                    $this->urlHelper->getEncodedUrl($url),
            )
        );
    }


    protected function _getBestSellingCollection()
    {
        $orderItemCol = $this->objectManager->get('MagentoSalesModelResourceModelOrderItemCollectionFactory')->create()
            ->addFieldToSelect(('product_id'))
            ->addFieldToFilter('parent_item_id', array('null' => true));
        $orderItemCol->getSelect()
            ->columns(array('ordered_qty' => 'SUM(`main_table`.`qty_ordered`)'))
            ->group('main_table.product_id')
            ->joinInner(
                array('sfo' => $orderItemCol->getTable('sales_order')),
                "(main_table.order_id = sfo.entity_id) AND (sfo.state <> 'canceled')",
                ()
            );
        $collection = $this->_getAllProductProductCollection();
        $collection->getSelect()
            ->joinLeft(
                array('sfoi' => $orderItemCol->getSelect()),
                'e.entity_id = sfoi.product_id',
                array('ordered_qty' => 'sfoi.ordered_qty')
            )
            ->where('sfoi.ordered_qty > 0')
            ->order('ordered_qty desc');
        return $collection;
    }

    protected function _getNewCollection()
    {
        $todayStartOfDayDate = $this->_localeDate->date()->setTime(0, 0, 0)->format('Y-m-d H:i:s');
        $todayEndOfDayDate = $this->_localeDate->date()->setTime(23, 59, 59)->format('Y-m-d H:i:s');
        /** @var $collection MagentoCatalogModelResourceModelProductCollection */
        $collection = $this->_getAllProductProductCollection();        
        $collection = $this->_addProductAttributesAndPrices(
            $collection
        )->addStoreFilter()->addAttributeToFilter(
            'news_from_date',
            (
                'or' => (
                    0 => ('date' => true, 'to' => $todayEndOfDayDate),
                    1 => ('is' => new Zend_Db_Expr('null')),
                )
            ),
            'left'
        )->addAttributeToFilter(
            'news_to_date',
            (
                'or' => (
                    0 => ('date' => true, 'from' => $todayStartOfDayDate),
                    1 => ('is' => new Zend_Db_Expr('null')),
                )
            ),
            'left'
        )->addAttributeToFilter(
            (
                ('attribute' => 'news_from_date', 'is' => new Zend_Db_Expr('not null')),
                ('attribute' => 'news_to_date', 'is' => new Zend_Db_Expr('not null')),
            )
        )->addAttributeToSort(
            'news_from_date',
            'desc'
        );
        return $collection;
    }

    protected function _getAllProductProductCollection()
    {
        $collection = $this->productCollectionFactory->create();
        $collection->setVisibility($this->catalogProductVisibility->getVisibleInCatalogIds());

        $collection = $this->_addProductAttributesAndPrices($collection)
            ->addStoreFilter()
            ->setPageSize($this->getPageSize())
            ->setCurPage($this->getRequest()->getParam(self::PAGE_VAR_NAME, 1));

        if ($productIds = $this->getData('product_ids')) {
            if (!is_array($productIds)) {
                $productIds = explode(',', $productIds);
            }
            $collection->addFieldToFilter('entity_id', ('in' => $productIds));
            $productIds = implode(',', $productIds);
            $collection->getSelect()->order(new Zend_Db_Expr("FIELD(e.entity_id, $productIds)"));
        }
        $conditions = $this->getConditions();
        $conditions->collectValidatedAttributes($collection);
        $this->sqlBuilder->attachConditionToCollection($collection, $conditions);

        return $collection;
    }

    public function createCollection()
    {
        $isAjax = !($this->getData('ajax_load'));
        $collection = null;
        if ($isAjax) {
            $displayType = $this->getDisplayType();
            switch ($displayType) {
                case 'all_products':
                    $collection = $this->_getAllProductProductCollection();
                    break;
                case 'bestseller_products':
                    $collection = $this->_getBestSellingCollection();
                    break;
                case 'new_products':
                    $collection = $this->_getNewCollection();
                    break;
            }
            $sort = explode(' ', $this->getData('order_by'));
            $collection->addAttributeToSort($sort(0), $sort(1));

            $this->_eventManager->dispatch(
                'catalog_block_product_list_collection',
                ('collection' => $collection)
            );
        }
        return $collection;
    }

    /**
     * Return identifiers for produced content
     *
     * @return array
     */
    public function getIdentities()
    {
        return (MagentoCatalogModelProduct::CACHE_TAG);
    }

    public function subString($str, $strLenght)
    {
        $str = $this->stripTags($str);
        if(strlen($str) > $strLenght) {
            $strCutTitle = substr($str, 0, $strLenght);
            $str = substr($strCutTitle, 0, strrpos($strCutTitle, ' '))."…";
        }
        return $str;
    }

    public function getTemplate()
    {
        $isAjax = !($this->getData('ajax_load'));
        if ($isAjax){
            $template = $this->getData('filter_template');
            if($template == 'custom') {
                return $this->getData('custom_template');
            } else {
                return $template;
            }
        } else {
            return 'Codazon_ProductFilter::ajax/first_load.phtml';
        }
    }

    public function getElementShow()
    {
        if (!$this->_show) {
            $this->_show = explode(',', $this->getData('show'));
        }
        return $this->_show;
    }

    public function isShow($item)
    {
        return in_array($item, $this->getElementShow());
    }

    public function getImage($product, $imageId, $attributes = ())
    {
        $width = $this->getData('thumb_width');
        $height = $this->getData('thumb_height');
        $attributes = array('resize_width' => $width, 'resize_height' => $height);

        $imageBuilder = $this->customImageBuilderFactory->create();
        return $imageBuilder->setProduct($product)
            ->setImageId($imageId)
            ->setAttributes($attributes)
            ->create();
        return $html;
    }

    public function getBlockId()
    {
        return uniqid("cdz_block_");
    }

    public function getFilterData()
    {
        if (!$this->_filterData) {
            $this->_filterData = (
                'is_ajax'               =>  1,
                'title'                 =>  $this->getData('title'),
                'display_type'          =>  $this->getData('display_type'),
                'products_count'        =>  $this->getData('products_count'),
                'order_by'              =>  $this->getData('order_by'),
                'show'                  =>  $this->getData('show'),
                'thumb_width'           =>  $this->getData('thumb_width'),
                'thumb_height'          =>  $this->getData('thumb_height'),
                'filter_template'       =>  $this->getData('filter_template'),
                'custom_template'       =>  $this->getData('custom_template'),
                'show_slider'           =>  $this->getData('show_slider'),
                'conditions_encoded'    =>  $this->getData('conditions_encoded'),
                'slider_nav'            => (int)$this->getData('slider_nav'),
                'slider_dots'           => (int)$this->getData('slider_dots'),
                'slider_autoplay'       => (int)$this->getData('slider_autoplay'),
                'slider_autoplay_timeout' => $this->getData('slider_autoplay_timeout'),
                'total_cols'            => (int)$this->getData('total_cols'),
                'total_rows'            => (int)$this->getData('total_rows'),
                'slider_margin'         => (int)$this->getData('slider_margin'),
                'cache_lifetime'        => $this->getData('cache_lifetime'),
                'product_ids'           => $this->getData('product_ids'),
                'cache_key_info'        => $this->getCacheKeyInfo(),
            );
            $adapts = array('1900', '1600', '1420', '1280','980','768','480','320','0');
            foreach ($adapts as $adapt) {
                $this->_filterData('items_' . $adapt) = (float)$this->getData('items_' . $adapt);
            }
        }
        return $this->_filterData;
    }

    public function getSliderData() {
        if (!$this->_sliderData) {
            $this->_sliderData = (
                'nav'       => (bool)$this->getData('slider_nav'),
                'dots'      => (bool)$this->getData('slider_dots'),
                'autoplay'  => (bool)$this->getData('slider_autoplay'),
                'autoplayTimeout' => $this->getData('slider_autoplay_timeout') ? : 5000
            );
            $adapts = array('1900', '1600', '1420', '1280','980','768','480','320','0');
            foreach ($adapts as $adapt) {
                 $this->_sliderData('responsive')($adapt) = ('items' => (float)$this->getData('items_' . $adapt));
            }
            $this->_sliderData('margin') = (float)$this->getData('slider_margin');
        }
        return $this->_sliderData;
    }

    public function getProductDefaultQty($product)
    {
        $qty = $this->getMinimalQty($product);
        $config = $product->getPreconfiguredValues();
        $configQty = $config->getQty();
        if ($configQty > $qty) {
            $qty = $configQty;
        }

        return $qty;
    }

    public function getQuantityValidators()
    {
        $validators = ();
        $validators('required-number') = true;
        return $validators;
    }

    public function getProductDetailsHtml(MagentoCatalogModelProduct $product)
    {
        $renderer = $this->getDetailsRenderer($product->getTypeId());
        if ($renderer) {
            if (get_class($renderer) == 'MagentoSwatchesBlockProductRendererListingConfigurableInterceptor') {
                return '';
            }
            $renderer->setProduct($product);
            return $renderer->toHtml();
        }
        return '';
    }

    public function getSwatchesBlock()
    {
        return $this->getLayout()->createBlock('MagentoSwatchesBlockProductRendererListingConfigurable')
            ->setTemplate('Codazon_ProductFilter::swatches/renderer.phtml')
            ->setData(('thumb_width' => $this->getData('thumb_width'), 'thumb_height' => $this->getData('thumb_height')));
    }
}

The Magento PageBuilder Plugin Catalog Block Product ProductsListPlugin.php file is as follows:

sorting = $sorting;
    }

    /**
     * Allow to sort product collection
     *
     * @param MagentoCatalogWidgetBlockProductProductsList $subject
     * @param MagentoCatalogModelResourceModelProductCollection $result
     * @return MagentoCatalogModelResourceModelProductCollection
     */
    public function afterCreateCollection(
        MagentoCatalogWidgetBlockProductProductsList $subject,
        MagentoCatalogModelResourceModelProductCollection $result
    ) {

        $sortOption = $subject->getData('sort_order');
        if (isset($sortOption)) {
            $sortedResult = $this->sorting->applySorting($sortOption, $result);

            return $sortedResult;
        } else {
            return $result;
        }
    }

    /**
     * Include sort order in cache key
     *
     * @param MagentoCatalogWidgetBlockProductProductsList $subject
     * @param array $cacheKeys
     * @return array
     */
    public function afterGetCacheKeyInfo(MagentoCatalogWidgetBlockProductProductsList $subject, array $cacheKeys)
    {
        $cacheKeys() = $subject->getData('sort_order');
        return $cacheKeys;
    }
}

magento2 file exists, but 404 for jquery-ui-1.9.3.2.js only one file

I have updated Magento 2.3.2 from 2.3.0. And get this error in the admin panel.
GET https:///pub/static/adminhtml/Magento/backend/nl_NL/jquery/jquery-ui-1.9.2.js net::ERR_ABORTED 404 (Not Found),
I have already tried it:

sudo php bin / magento setup: upgrade
sudo php bin / magento setup: di: compile
php bin / magento setup: static content: deploy -f
php bin / magento setup: static content: deploy -f –theme Magento / backend
sudo php bin / magento cache: clean
sudo chmod -R 0777 pub var generated

Folder files and other files in the same folder work. Same file permissions and user groups.

Please help me to solve this problem.

magento2 – Can only a simple product be assigned to a configurable product?

I use the Firebear Studio Import / Export extension to import both simple and configurable products. It works great unless the configuration product contains only a simple product as a variation. Then it skips that until it finds another SKU that (I think) has more than one variation. In a demo everything was imported correctly, with the exception of the configuration products, which contain only one variation.

For consistency, I would like it that way, even if there was a variation. Is that simply impossible in M2 or do you have to change your code? Thank you very much!!

magento2 – Why is program-controlled updating of stocks and prices so slow?

I'm trying to update the inventory and price of the products in a Magento 2.3 shop via a CSV file.

The file I have has about 5,000 lines, and about 3,500 of them correspond to products in Magento. About 1,500 of them had to update the price or the item number or both, the rest had the right price and the right amount.

When I ran this, it took about 6 hours.

I used the following code (to focus on the relevant bits).

An interesting observation that I made is that the first rd. 200 products went very fast, but then it almost came to a standstill and it took several minutes per product.

Can someone enlighten me, (a) why this is so slow and (b) are there better ways to achieve this?

/** @var MagentoCatalogInventoryApiStockRegistryInterface $stockRegistry */
/** @var MagentoCatalogModelResourceModelProduct $productResourceModel */
/** @var MagentoFrameworkAppCacheManager $cacheManager */
/** @var MagentoIndexerModelIndexerFactory $indexerFactory */
/** @var MagentoCatalogModelResourceModelProductCollectionFactory $productCollection */

$records = $csv->getRecords(); //returns all the CSV records in an array

// keep track of updated entity ids, so that we can reindex.
$updatedProductStocks = ();
$updatedProductPrices = ();

// Get a list of existing products in an array so we don't hit the database all the time, unless we really need to
$existingProducts = ();

$collection = $productCollection->create();
$collection->addAttributeToSelect('price')
    ->addAttributeToSelect('sku')
    ->addAttributeToSelect('name')
    ->joinField(
        'qty', 'cataloginventory_stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left'
    );

// index by sku so we can find it easily
foreach( $collection as $_product ) {
    $existingProducts($_product->getSku()) = $_product;
}

foreach ($records as $record) {

    echo "SKU: ".$record('Product Code');

    if( !array_key_exists( $record('Product Code'), $existingProducts ) ) {
        echo "Product with SKU ".$record('Product Code')." not found";
    } else {
        $product = $existingProducts($record('Product Code') );
        echo "Name: ".$product->getName();
        // update qty if changed
        if( $product->getData('qty') !== $record('Quantity In Stock') ) {
            $stockItem = $stockRegistry->getStockItemBySku($record('Product Code'));
            $stockItem->setData('qty', $record('Quantity In Stock'));
            $stockItem->setData('is_in_stock', ($record('Quantity In Stock') > 0 ) ? 1 : 0); 
            $stockItem->save();
            array_push($updatedProductStocks, $product->getId());
            echo 'Quantity updated to '.$record('Quantity In Stock');
        }

        // update price if changed
        if( $product->getPrice() !== $record('Sales Price') ) {
            $product->setPrice($record('Sales Price'));
            $productResourceModel->saveAttribute($product,'price');
            array_push($updatedProductPrices, $product->getId());
            echo 'Price updated to '.$record('Sales Price');
        }
    }
}

// reindex and refresh cache where needed
if( $counter('updatedStock') > 0 ) {
    $stockIndexer = $indexerFactory->create();
    $stockIndexer->load('cataloginventory_stock');
    $stockIndexer->reindexList($updatedProductStocks);
}

if( $counter('updatedStock') > 0 ) {
    $priceIndexer = $indexerFactory->create();
    $priceIndexer->load('catalog_product_price');
    $priceIndexer->reindexList($updatedProductPrices);
}

if( $counter('updatedPrice') > 0 || $counter('updatedStock') > 0 ) {
    $cacheManager->clean($cacheManager->getAvailableTypes());
}

magento2 – No such directory

Magento 2, version 3.2.x worked fine, but after upgrading to version 2.3.3, error 500 was displayed. I've tried to execute, compile, reindex, clear the permissions on folders and files … but this is still not working. When I check the file exeptions.log while hosting, I found the following error. Any suggestions? Thank you so much!

main.CRITICAL: SQLSTATE(HY000) (2002) No such file or directory {"exception":"(object) (Zend_Db_Adapter_Exception(code: 2002): SQLSTATE(HY000) (2002) No such file or directory at /home/.../public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:144, PDOException(code: 2002): SQLSTATE(HY000) (2002) No such file or directory at /home/.../public_html/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php:128)"} ()

magento2 – Create a custom M2 grid and render data from a custom table problem

I tried to follow these tutorials:

In both cases, however, I had a blank page. Without a grid!

This is my controller path: path/to/vendor/atty31/subscription/Controller/Adminhtml/Subscription/Index.php,
This is my controller content:

resultPageFactory = $resultPageFactory;
    }

    public function execute()
    {
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->prepend((__('View Subscriptions')));

        return $resultPage;
    }

    protected function _isAllowed()
    {
        return $this->_authorization->isAllowed('Atty31_Subscription::subscription_index');
    }
} 

This is my di.xml Path: path/to/vendor/atty31/subscription/etc/di.xml and it's content:



    
        
            atty31_subscription
            Atty31SubscriptionModelResourceModelSubscription
        
    
    
        
            
                Atty31SubscriptionModelResourceModelSubscriptionCollection
            
        
    

and the layout XML path: /path/to/vendor/atty31/subscription/view/adminhtml/layout/subscription_subscription_index.xml and it's content:



    
    
        
            
        
    

and finally the path of the UI component file: path/to/vendor/atty31/subscription/view/adminhtml/ui_component/atty31_subscription_grid.xml
and it's content:


    
        
            atty31_subscription_grid.atty31_subscription_grid_data_source
            atty31_subscription_grid.atty31_subscription_grid_data_source
        
        atty31_subscription_columns
        
            
                add
                Add New Blog
                primary
                */*/new
            
        
    
    
        
            MagentoFrameworkViewElementUiComponentDataProviderDataProvider
            atty31_subscription_grid_data_source
            id
            id
            
                
                    Magento_Ui/js/grid/provider
                    
                    
                        blog_id
                    
                
            
        
    
    
        
        
            
                
                    id
                
            
        
        
            
                
                    text
                    asc
                    ID
                
            
        
        
            
                
                    text
                    asc
                    Customer ID
                
            
        
        
            
                
                    dateRange
                    Magento_Ui/js/grid/columns/date
                    date
                    Created At
                
            
        
    

Does anyone give some advice on what to check next? or perhaps point out the mistake I made?

Thank you in advance!

magento2 – Avoid Magento 2 automatically adding a tax rate to the gross gross prices uploaded

I load my prices as gross prices incl. all control.

Nevertheless, I would like the bill to display the tax rate without Magento automatically adding it to the checkout.
I need Magento to understand my product prices as gross prices and not as net prices. The same applies to shipping costs.

Example:

Product price: 10

Tax rate: 10%

Magento total: 11

What I need:

Product price: 10

Tax rate: 10%

Total Magento: 10

(Bills: Product price: 9.09, Tax rate: 10%, Total price: 10)

Basically like any other store. Shown are the gross prices that contain the tax, but the bill shows the net price + the tax, which then represents the total price (which I have uploaded for the product).

magento2 – preselection of the shipping method (tablerate_bestway) on the PayPal Express Review Page in Magento 2

I've tried to select the shipping method (in my case tablerate_bestway) from the drop-down box on the Paypal Express review page, as we have only one method to choose from. added this to the end of mytheme / Magento_Paypal / templates / express / review.phtml and works fine:

but in addition, I am looking for a way to update the page in the same script to get the shipping costs in the order totals block (to show the shipping cost for the current order before checking out). Currently, it will only be reloaded when the drop-down feature is re-selected. I use Magento 2.3.2

Help really gifted.