8 – How to get a view result programmatically without exposed filters respected

I have some views of display page which I do not want to show to public if there would not be any result when accessed without any exposed filters set. I have a custom views access plugin and a custom access checking class which can handle the access granting.

My idea so far is that I would like to run the view a first time during access checking without exposed filters. In this way I could find out if the view would ever deliver any results. I tried it in the following way:

  $view = Views::getView($view_id);
  $result = $view->total_rows;

The problem is: as soon as an user comes to this page with query parameters in the url set by exposed filters these exposed filters are used for this view query as well. I did not find any way to tell the class in $view to execute without exposed filters. I even tried to set these exposed filters data in the following ways but even then the filter data in the query parameters is still used to filter the result set:

  $view = Views::getView($view_id);
  $view->exposed_data = ();
  $view->exposed_raw_input = ();
  $result = $view->total_rows;

I want to achieve that in this way because I want to use this logic for several views. It would be so smart to simply re-use the arguments and filters set in the views instead of hardcoding a new custom database query as the settings in the views might change. I hope someone can help me.

php – Magento 2, programmatically create configurable products

Hello I have the necessity of creating both simpe and configurable products.

This is what (following online guidelines) I have right now:

$bootstrap = Bootstrap::create(BP, $params);
$objectManager = $bootstrap->getObjectManager();
$state = $objectManager->get('MagentoFrameworkAppState');
$salt = rand(10, 999);

$simple_product = $objectManager->create('MagentoCatalogModelProduct');
$simple_product->setSku('test-simple' . $salt);
$simple_product->setName('test name simple' . $salt);
$simple_product->setAttributeSetId(9); //my own attribute set 

$simple_product->setData('157', '9'); // my custom attribute flavor and it's assigned value

$simple_product->setCategoryIds(array(14)); //it's category
    'use_config_manage_stock' => 0, //'Use config settings'?
    'manage_stock' => 1, //manage stock
    'min_sale_qty' => 1, //Minimum Qty Allowed in Shopping Cart
    'max_sale_qty' => 2, //Maximum Qty Allowed in Shopping Cart
    'is_in_stock' => 1, //Stock Availability
    'qty' => 100 //qty

$productRepository = $objectManager->get('MagentoCatalogApiProductRepositoryInterface');
$product = $productRepository->getById($simple_product->getId());
$product->setFlavor('BBBB');  //my custom attribute is called flavor and BBBB it's is value
$product->getResource()->saveAttribute($product, 'flavor');

$simple_product_id = $simple_product->getId(); //get ID
echo "simple product id: ".$simple_product_id."n";

This works just perfect, now I’d like to create a configurable product and assign this product to it:

$configurable_product = $objectManager->create('MagentoCatalogModelProduct');
$configurable_product->setSku('test-configurable' . ++$salt);
$configurable_product->setName('test name configurable' . ++$salt);
    'use_config_manage_stock' => 0, 
    'manage_stock' => 1, 
    'is_in_stock' => 1, 
    'qty' => 999

$configurable_product->getTypeInstance()->setUsedProductAttributeIds(array(157),$configurable_product); //attribute ID of attribute flavor

$configurableAttributesData = $configurable_product->getTypeInstance()->getConfigurableAttributesAsArray($configurable_product);


$configurableProductsData = array();
$configurableProductsData($simple_product_id) = array( //our simple product ID
    '0' => array(
        'label' => 'gusto', //attribute label
        'attribute_id' => '157', //attribute ID of attribute 'flavor' in my store
        'value_index' => '9', //value of 'BBBB' index of the attribute 
        'is_percent'    => 0,
        'pricing_value' => '10',



echo "configurable product id: ".$configurable_product->getId()."n";

I successifully create both products, but the simple is not associated with the configurable one.

Of course I do something wrong…. can you please guide me in the right direction?

theming – how to programmatically display a view embedded in code with a template

I have a page I’m generating in a module. I’m using this code to get a block from a view:

$block = views_embed_view('testimonials', 'block_1');
$view = Drupal::service('renderer')->render($block);
$my_block = $view->__toString();

and display it in the generated HTML:

<div class='testimonials'>$my_block</div>

When I view the page in a browser and inspect it (with twig.debug=true), I don’t see the output rendered by a block template. If I display the block in a region by using the block layout page, I do see there is twig involved.

What do I have to do to make it use a template when I create the block in code? I think the correct answer would be to create a twig template for the entire page, and pull the block into the page template. But I’m curious if it could also be done this way.

How can I add an BCC or CC email with programmatically?

I am sending email programmatically and I am using plugin.manager.mail to send email, I want to add a CC ó BCC.

Do you know the way to achieve it?

macos – How to disable auto spellcheck options programmatically?

macos – How to disable auto spellcheck options programmatically? – Ask Different

forms – How to add and associate Paragraphs to Media Library Images Programmatically

Good day everyone,

Our client wants to have this feature where he can upload/reuse multiple images for an article content type. This can be achieved using a Media Library, where I find it tricky is each images will have additional fields(Alt, Copyright, Description fields), I’ve tried adding the additional fields to the Image Media Type but once the node is saved, their value will be associated to the image’s metadata. The proper functionality should be is when the node is saved, the Alt and Description of the images should be associated to the node’s metadata because Images can be reusable to another node, and the values of Alt and Description varies to each node.

So I talked with someone who really knows a lot about Drupal. He suggested that I keep the Media Library, and create a Paragraph Type. I called it ‘Image Library Paragraphs’, this paragraph has Image, Alt, Copyright, and Description fields. This way the Paragraph can hold the id of the image, alt, description and the node’s ID. In theory, what we’re trying to do here is everytime the user uploads/select an image. We must find a way to associate that image and add corresponding paragraph for each of those images. So if the user uploads/selects 3 images. It will also automatically create 3 paragraphs for those images. We also would need to reconstruct the layout of the form to somehow “blend” the image and its corresponding paragraphs. And since the position of the images can be changed, we also need to somehow reposition its paragraph accordingly to the image.

It’s tricky and a lot of work, honestly it’s even beyond my Drupal skills. But any help to the right direction will truly be appreciated. I haven’t even tried creating a really complex custom module. But would really want to learn how this can be done. Thank you in advance.

In theory this is what it’s gonna look like
enter image description here

enter image description here

php – Magento2.4.2 Create order Programmatically not working

I’ve tried a viral solution and followed this https://webkul.com/blog/create-quote-and-order-programmatically-in-magento2/

The quote is created successfully but error occurred when place order

$orderId = $this->cartManagementInterface->placeOrder($quote->getId());

And the following error occurred

Type Error occurred when creating object: MagentoInventoryIndexerModelQueueReservationData, Argument 2 passed to MagentoInventoryIndexerModelQueueReservationData::__construct() 

must be of the type int, null given, called in /var/www/html/magento2/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php on line 121

send commands programmatically to a VPS

I have created a snapshot on digital ocean with a NodeJs app files and I want to create new vps with the same snapshots. However, i have to … | Read the rest of https://www.webhostingtalk.com/showthread.php?t=1843568&goto=newpost

DreamProxies - Cheapest USA Elite Private Proxies 100 Private Proxies 200 Private Proxies 400 Private Proxies 1000 Private Proxies 2000 Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive Proxies-free.com New Proxy Lists Every Day Proxies123