タグ付けされた質問 「filter」

Magentoでのフィルタリング(レイヤードナビゲーション、コレクションフィルタリング)に関する質問を示します

2
Magento 2オブジェクトリポジトリのフィルタリング
Magento 2では、製品リポジトリを使用して製品属性でフィルタリングできますか? Magento 2では、検索条件オブジェクトを使用できます \Magento\Framework\Api\SearchCriteriaInterface $searchCriteria, およびリポジトリ \Magento\Catalog\Api\ProductRepositoryInterface $productRepository, オブジェクトのリストを取得するには $searchCriteria->getPageSize(10); $list = $productRepository->getList($searchCriteria); ただし、searchCriteriaオブジェクトには、直接フィルタリング機能はありません(と思われますか?)。検索条件クラスには、filterGroupsと呼ばれるものを追加するためのメソッドがあります #File: lib/internal/Magento/Framework/Api/SearchCriteria.php public function getFilterGroups() { $filterGroups = $this->_get(self::FILTER_GROUPS); return is_array($filterGroups) ? $filterGroups : []; } public function setFilterGroups(array $filterGroups = null) { return $this->setData(self::FILTER_GROUPS, $filterGroups); } しかし、PHPの型指定されていない配列のおかげで、正確にフィルターグループが何であるかは明確ではありません。 Magento 2リポジトリを使用して次のようなことを行うにはどうすればよいですか [この特定のSKU]を持つすべての製品を表示する [この日付]以降に作成されたすべての製品を表示する 等

3
addAttributeToFilterのマルチ条件(ANDおよびAND内のAND)
addAttributeToFilterでマルチ条件を作成する方法は? このようなSQLクエリの結果が必要です(画像を添付): WHERE ((`e`.`news_from_date` > '2013-09-12') OR (`e`.`news_to_date` < '2013-09-12')) AND ((((`e`.`special_price` IS NULL))) OR (((`e`.`special_price` IS NOT NULL)) AND ((`e`.`special_from_date` < '2013-09-12') OR (`e`.`special_to_date` > '2013-09-12')))) $collection->addAttributeToFilter('special_price', array('null'=>'special_price'), 'left'); ありがとうございました
19 filter 

4
グリッドに列を追加(オブザーバー)-where句の列 'store_id'があいまいな問題
オブザーバーアプローチを使用して、注文グリッドに列を追加しています。 イベントで-> sales_order_grid_collection_load_beforeコレクションに結合を追加しています イベントで-> core_block_abstract_prepare_layout_beforeグリッドに列を追加しています 編集詳細情報の: イベント(1)の場合: public function salesOrderGridCollectionLoadBefore($observer) { $collection = $observer->getOrderGridCollection(); $collection->addFilterToMap('store_id', 'main_table.store_id'); $select = $collection->getSelect(); $select->joinLeft(array('oe' => $collection->getTable('sales/order')), 'oe.entity_id=main_table.entity_id', array('oe.customer_group_id')); } イベント(2)の場合: public function appendCustomColumn(Varien_Event_Observer $observer) { $block = $observer->getBlock(); if (!isset($block)) { return $this; } if ($block->getType() == 'adminhtml/sales_order_grid') { /* @var $block Mage_Adminhtml_Block_Customer_Grid */ …

2
UIコンポーネントを使用せずにMagento 2管理グリッドフィルターの日付形式を変更するにはどうすればよいですか?
以下はsome_grid_block.xml、 カレンダーフィルターの日付形式を変更するにはどうすればよいですか。 <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="adminhtml.qrcode.grid.container"> <block class="Oneteam\Qrcode\Block\Grid" name="adminhtml.qrcode.grid" as="grid"> <arguments> <argument name="id" xsi:type="string">QrcodeGrid</argument> <argument name="dataSource" xsi:type="object">Oneteam\Qrcode\Model\ResourceModel\Qrcode\Collection</argument> <argument name="default_sort" xsi:type="string">qr_id</argument> <argument name="default_dir" xsi:type="string">desc</argument> </arguments> <block class="Magento\Backend\Block\Widget\Grid\Column\Filter\Date"> <filterRange name="created_at" class="Magento\Backend\Block\Widget\Grid\Column\Filter\Date"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="dataScope" xsi:type="string">created_at</item> <item name="label" xsi:type="string" translate="true">Created</item> </item> </argument> <filterDate name="from"> …

1
Magento 2:定義済みのフィルター値を使用して管理グリッドを読み込むにはどうすればよいですか?
事前定義されたフィルターを使用して、管理者にカスタムグリッドへのリンクを作成したい。グリッドはUIリストコンポーネント(XML)でform_id作成され、次のように設定された列があります。 <column name="form_id"> <argument name="data" xsi:type="array"> <item name="config" xsi:type="array"> <item name="filter" xsi:type="string">textRange</item> <item name="label" xsi:type="string" translate="true">Form id</item> </item> </argument> </column> グリッドは正常に機能します。フィルターを適用でき、すべてがうまく機能します。グリッドはXHRリクエストで適切に更新されます。 しかし...ある時点でフィルターの値を事前に定義できるようにしたい。たとえば、ID = 3でフィルターされたときにグリッドを開くことができます。 そのため、XHRリクエストと同じURLパラメーターを使用してページをロードし、必要なパラメーターのみを追加するだけで済みます。 ?namespace=form_response_listing&search=&filters[placeholder]=true&filters[form_id][from]=3&filters[form_id][to]=3&paging[pageSize]=20&paging[current]=1 と同様: ?filters[form_id][from]=3&filters[form_id][to]=3 両方とも成功しませんでした。では、URLを使用してフィルターを事前に入力するにはどうすればよいですか? 編集: これが他の質問と重複しているかどうかはわかりません(以下のコメントに記載されています)。私の場合、グリッドのコレクションとして仮想タイプを使用しています。 <virtualType name="Vendor\Module\Model\ResourceModel\Response\Grid\Collection" type="Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult"> <arguments> <argument name="mainTable" xsi:type="string">vendormodule_form_response</argument> <argument name="resourceModel" xsi:type="string">Vendor\Module\Model\ResourceModel\Response</argument> </arguments> </virtualType> したがって、グリッドウィジェット用の物理的なBlockクラスを持っているのではなく、XMLをリストするUIコンポーネントで純粋に作成されています。 それにもかかわらず、言及された質問が私のユースケースに役立つかどうかとにかくチェックします。
14 magento2  admin  grid  filter 

1
製品コレクションのカスタムソート順を指定する方法
製品IDの配列に基づいて製品コレクションを作成し、ID配列に基づいてコレクションを並べ替えようとしています。 $productIds = array(318,310,311); $collection = Mage::getModel('catalog/product') ->getCollection() ->setOrder('entity_id', 'asc') // This will not do the job ->addAttributeToSelect('*') ->addAttributeToFilter('status', 1) ->addAttributeToFilter('entity_id', array( 'in' => $productIds, )); $productIds配列に表示されるように収集されたものをソートしたいのですが318, 310, 311、上記のコードはのようなコレクションソートを返します310,311, 312。 以下に示すように、プレーンMySQLクエリを使用せずにこれは可能ですか? SELECT * FROM catalog_product_entity WHERE entity_id IN (318, 310, 311) ORDER BY FIELD(entity_id, 318, 310, 311);

1
Magento 2-階層化されたナビゲーションとページネーションを備えたすべての製品ページ
私は、すべての製品ページを作成したいですfilters、toolbar、pagination。 名前で新しいカテゴリを作成し、その中のAll Productsすべての製品を割り当てることで、それを行うことができます。しかし、これは良いアプローチではないと思います。まるで、新製品がWebサイトに追加されるたびに、すべての製品カテゴリにも追加される必要があるからです。人為的ミスの可能性はたくさんあります。 ルートレベルのカテゴリでカテゴリページを呼び出す方法はありますか?からのようにID: 2 誰かが私のためにコードを書きたくない場合でも大丈夫ですが、誰かが私がそれを行うためのアプローチを見つけるのを助けることができればそれは素晴らしいでしょう。


5
在庫数量で製品を入手するにはどうすればよいですか?
私は次のコードを持っています: umask(0); Mage::app(); $category =new Mage_Catalog_Model_Category(); $category->load($cid); if ($status == "2") { $products = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*') ->addFieldToFilter('status',Mage_Catalog_Model_Product_Status::STATUS_DISABLED); $products->load(); } if ($status == "1") { $products = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*'); $products->load(); } 製品をフィルタリングするために在庫数量のフィルターを追加したいのですが、試しました: $products = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect('*'); **->addAttributeToFilter('qty', array("gt" => 0));** しかし、成功していませんか?
10 product  filter 

4
カテゴリーに含まれない製品をフィルタリングする方法は?
これが私のコードです: $catIds = array(7,8,9); $collection = Mage::getModel('catalog/product')->getCollection() ->addAttributeToSelect("*"); ->addAttributeToFilter('category_ids', array('nin' => $catIds)); カテゴリIDのリストに含まれていないすべての製品を取得したいのですが、コードで期待した結果が得られませんでした。道を教えてください、ありがとう。

2
Magento 2:複数のカテゴリで製品コレクションをフィルタリングする(Magento 2.1)
Magento 2.1.0を使用していますが、現在、複数のカテゴリで製品コレクションをフィルタリングするのが困難です。私はそれを機能させるために2つ以上の方法を使用しましたが、機能しません。 仮定: $catalog_ids = [618, 619, 620]; NULLを返します $productCollection = $this->productCollectionFactory->create() ->addAttributeToSelect('*') ->addCategoriesFilter(array('in' => $catalog_ids)); 例外を返します:無効な属性名:category_id $productCollection = $this->productCollectionFactory->create() ->addAttributeToSelect('*') ->addAttributeToFilter('category_id', array( 'finset' => $catalog_ids )); 構文エラーまたはアクセス違反を返します $productCollection = $this->productCollectionFactory->create() ->addAttributeToSelect('*') ->addAttributeToFilter('category_ids', array( 'finset' => $catalog_ids )); この作品を作成したり、この作品にリンクを張ったりする方法についてアドバイスはありますか?

1
Magento 2:レイヤードナビゲーションでファセットデータはどのように機能しますか?
レイヤードナビゲーションの価格帯を除き、すべてが正常に機能しているカテゴリページでカスタムフィルターのモジュールを作成しました。 誰でも私にgetFacetedData( 'price')がmagento2でどのように機能するか説明してください $productCollection->getFacetedData('price'); この関数は、フィルタリングされたコレクションではなく、デフォルトの製品コレクションに基づいた価格帯を提供します。 参考までに、次のようにコレクションをフィルタリングしました。 $productCollection = $layer->getProductCollection() ->clear() ->addAttributeToSelect(['name','price']) ->addAttributeToFilter('sku', array('in' => ['sku1','sku2']));

2
Magento 2:製品グリッドでフィルターをリセットする方法は?
私はへの設定ページごとに変更されている500にカタログ製品グリッドページ。製品の多くをロードできず、エラーが発生しました。これで何とかどこかに保存され、製品グリッドページにアクセスするたびに製品をロードできず、エラーが発生します。 製品グリッドページでフィルター設定をリセットするにはどうすればよいですか?

2
作成時間(今日、昨日、週、時間など)によるMagentoフィルターコレクション
作成日と「昨日」作成されたhetエントリでフィルタリングするカスタムコレクションがあります。 コレクションエントリ //dates are set in controller using setCreatedTime(Mage::getModel('core/date')->gmtDate()); 昨日作成(機能しません) //3 products items Yesterday //below filtering outputs incorrect entries $collection = Mage::getModel('things/things')->getCollection(); 試しましたが、正しくないエントリが出力されます。 //thought strtotime('yesterday') would work.. $collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('yesterday')))); $collection->addFieldToFilter('created_time', array('gt' => Mage::getModel('core/date')->date('Y-m-d H:i:s', strtotime('-1 day')))); $collection->addFieldToFilter('created_time', array('from'=> strtotime('-1 day', time()),'to'=> time(),'datetime' => true)); $fromDate = …

2
特定のカテゴリーのフィルター可能な属性を取得しようとしたときに空の結果を取得する
カテゴリのすべてのフィルター可能な属性を取得する必要があります。私はそのスニペットを使用しています: $category = Mage::getModel('catalog/category')->load($categoryId); $layer = Mage::getModel('catalog/layer'); $layer->setCurrentCategory($category); $attributes = $layer->getFilterableAttributes();//$attributes now is empty array カテゴリーにはフィルター可能な属性を持つ製品があり、カテゴリーでもオプションのアンカーが有効になりました。このコードはSOAP APIで使用します。 多分誰かが私がどこで間違えたか知っていますか?

弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.