Remove contextual filter programmatically in Drupal 7 Views

Is there a way to remove a contextual filter from a view programmatically? I have a view where, at times, I want to display it without the contextual filter active. This is the code I tried:

function MYMODULE_views_pre_view(&$  view, &$  display_id, &$  args) {   if ($  view->name == 'some_view') {     unset($  view->args);   } } 

I also tried the same code within hook_views_pre_execute.

Anyone know how to do this?

I need to filter product collection by category id and color attribute

I need to get product collection by category id and color attribute. But It’s not working.

Here is my code:

$  objectManager =  \Magento\Framework\App\ObjectManager::getInstance(); $  categoryFactory = $  objectManager->get('\Magento\Catalog\Model\CategoryFactory'); $  category = $  categoryFactory->create()->load($  cat_ids); $  categoryProducts = $  category->getProductCollection(); $  categoryProducts->addAttributeToSelect('*')->addAttributeToSort('position', 'ASC'); $  categoryProducts->addAttributeToFilter('color', array('in',29)); 

Here my Sql query:

SELECT 1 AS `status`, `e`.`entity_id`, `e`.`attribute_set_id`, `e`.`type_id`, `e`.`created_at`, `e`.`updated_at`, `e`.`sku`, `cat_index`.`position` AS `cat_index_position`, `e`.`entity_id`, `e`.`attribute_set_id`, `e`.`type_id`, `e`.`area`, `e`.`cost`, `e`.`created_at`, `e`.`description`, `e`.`gift_message_available`, `e`.`has_options`, `e`.`image`, `e`.`image_label`, `e`.`is_facebook`, `e`.`is_facebook_value`, `e`.`links_exist`, `e`.`links_purchased_separately`, `e`.`links_title`, `e`.`msrp`, `e`.`msrp_display_actual_price_type`, `e`.`name`, `e`.`news_from_date`, `e`.`news_to_date`, `e`.`price`, `e`.`price_type`, `e`.`price_view`, `e`.`product_brand`, `e`.`product_items`, `e`.`required_options`, `e`.`select_delivery_time`, `e`.`select_delivery_time_value`, `e`.`select_price_label`, `e`.`select_price_label_value`, `e`.`select_units`, `e`.`select_units_value`, `e`.`short_description`, `e`.`sku`, `e`.`sku_type`, `e`.`small_image`, `e`.`small_image_label`, `e`.`special_from_date`, `e`.`special_price`, `e`.`special_to_date`, `e`.`swatch_image`, `e`.`tax_class_id`, `e`.`thumbnail`, `e`.`thumbnail_label`, `e`.`ts_dimensions_height`, `e`.`ts_dimensions_length`, `e`.`ts_dimensions_width`, `e`.`updated_at`, `e`.`url_key`, `e`.`url_path`, `e`.`visibility`, `e`.`weight`, `e`.`weight_type` FROM `catalog_product_flat_1` AS `e` INNER JOIN `catalog_category_product_index_store1` AS `cat_index` ON cat_index.product_id=e.entity_id AND cat_index.store_id=1 AND cat_index.category_id='12' ORDER BY `cat_index_position` ASC, `cat_index`.`position` ASC 

Magento 2 : How to filter customer group collection?

Anybody have idea about how can i filter customer group pragmatically ?

I can able to get customer group collection by using below code.

$  customerGroupsCollection = $  objectManager->create('\Magento\Customer\Model\ResourceModel\Group\Collection');  print_r($  customerGroupsCollection->getData()); exit; 


[6] => Array     (         [customer_group_id] => 9         [customer_group_code] => first         [tax_class_id] => 3         [custom_shipping_amount] => 1200         [group_creator] => newnew         [group_creator_id] => 10         [group_code] => first         [total_members] =>          [group_validity] =>          [members_name] =>          [member_profile_image] =>          [group_shopping_amount] =>          [group_image] => /k/o/koala_1.jpg         [group_link] => first     ) 

Now i am trying to apply addAttributeToFilter but its not working !?

Anyone know what is missing ?

$  customerGroupsCollection = $  objectManager->create('\Magento\Customer\Model\ResourceModel\Group\Collection');  $  customerGroupsCollection->addAttributeToSelect('*')->addAttributeToFilter('group_link',['eq'=>'thisisfreshgroup']); print_r($  customerGroupsCollection->getData()); exit; 

Getting unDefined Method addAttributeToFilter.

Why does GMail still process incoming emails after I’ve deleted a filter?

I’ve a problem with Gmail.

Long time ago, I created a filter for incoming e-mails with a specific address, and gave them a specific label. A few weeks ago, I’ve deleted the filter and my filter-list is completely empty.

But incoming emails gets still the label from my old filter.

What can I do? There is no filter to delete, and Gmail labels the emails itself.

Magento 2 Rest Api – Is this searchCriteria filter correct?

I’m trying to retrieve

  • virtual products,
  • which have been modified before a certain date
  • and which still are in stock

I’m using this

/rest/V1/products?searchCriteria[filter_groups][0][filters][0][field]=updated_at&searchCriteria[filter_groups][0][filters][0][value]=2019-05-25 00:00:00 &searchCriteria[filter_groups][0][filters][0][condition_type]=lt




While this returns some results, I have picked one returned sku, marked it as out of stock, and tried the above search again.

My problem is, my test sku which I marked out of stock, is again appearing in that search.

Is my search query correct?

— edit —

I’m setting the test sku as out-of-stock like this:

PUT /rest/V1/products/test_sku/stockItems/1

DATA {“stockItem”:{“qty”:0}}

I’m hoping this is the right way to mark an item as out of stock

—- edit 2 —–

FYI: the “Display Out of Stock Products” in my Stores>Configuration>Catalog>Inventory is set to default “No”

Applescript to filter the clipboard

Let say I have this in my clipboard :

************TH4F    fsdfssdggg0878  Ex.US   Unknown 0   $  100.00 05/24/17 04:40  No Bonus     ************TH4F    fsdfssdggg0878  Un.UK   Unknown 0   $  50.00  05/20/17 04:44  No Bonus     

who can I only keep the total and add it in a list and same for the date ?

I’m a bit stuck on the script for now :

repeat with i in (get (the clipboard)'s text items)     return i end repeat 

Execute a view in code and pass multiple arguments to an exposed filter?

I am executing a View in code of a paragraph preprocess to allow dynamic listings. The user selects which content types they would like to show, and the View should return nodes of those types with the same taxonomy selected. The idea is they can add multiple paragraphs with different configuration, leveraging the same View just with different arguments.

In this view, Content Type is an exposed filter, set to allow multiple. Here is the code in the preprocess_paragraph hook:

$  types = $  paragraph->field_related_content_types->getValue(); $  content_types = [];  foreach ($  types as $  type) {   $  content_types[] = $  type['target_id']; }  $  view = Views::getView('related_content'); $  view->setDisplay('related_content_display'); $  view->setArguments(['type' => $  content_types]); $  view->setExposedInput(['type' => $  content_types]); $  view->preExecute(); $  view->execute();  if (count($  view->result)) {   $  variables['results'] = $  view->buildRenderable('related_content_display', ['type' => $  content_types]); } 

‘type’ is the filter name in the View. If I change it to only allow one value and pass it as a string, it works. So it seems like a syntax issue, but I cannot figure it out.

The method seems to indicate that this is possible:

  /**    * Sets the arguments for the view.    *    * @param array $  args    *   The arguments passed to the view.    */   public function setArguments(array $  args) {     // The array keys of the arguments will be incorrect if set by     // views_embed_view() or \Drupal\views\ViewExecutable:preview().     $  this->args = array_values($  args);   } 

Screen filter app may be phoning home

Being quite a tech geek and Android geek I usually always solve my Android problems on my own but this one is really puzzling me. I recently got a Galaxy A40 and realized that my eyes react very badly to the PWM emitted by this amoled screen. The only option if you’re unrooted to fix PWM is this app I found on the store called “Oled Saver”, it’s a screen filter app. The problem with this app is the mix of permissions it asks and I’m afraid it might record my screen and send it to the developer. “FULL INTERNET ACCESS” “ALLOW MODIFY SYSTEM SETTINGS” and it created a new section in the accessibility menu that I had to enable in order to run the app with no description of it (I guess that’s the permission it need to draw over the screen). It also needs storage write access among others. Once the screen filter starts a background process of around 80mb is created. What I’ve done is I’ve disabled background data usage for this app and constantly check the cache create by the app and it’s been at 119kb for a few days so I guess it’s not storing my screen recordings. And the data used by the app has always been zero, background and foreground. But all those internet related permissions must be there for a reason since the app has no ads. Expert question now: Could it be that the app is not sending data but the background process it created actually is? May it be that the restrictions of background data usage apply only the “the app” and NOT to the process it created?

Please help guys if my screen is recorded I could be hacked from head to toe and witout this app I can’t look at the display.

Magento2.3.0 any one use layered navigation with multi select checkbox using category and other attribute filter

I am using Magento2.3.0 community version and I have integrate all free version layer navigation but not working so my requirement is attribute option with checkbox select than not remove in existing filter section if any one know this type of feature available in extension please reply me link and name and compatible with my magneto version.

Thanks in advance