1

Shopify では、コレクションにデフォルトの並べ替え順序を設定できます。これはすばらしいことです。しかし、コレクションの製品リストをレンダリングする前に、デフォルトの並べ替え順序を変更する方法はありますか? 私が達成しようとしているのは、ページに「並べ替え」ドロップダウン メニューを配置することです。これにより、現在のリストを価格、ブランド、ベストセラー商品、アルファベット順などで並べ替えることができます。多くの最新のショッピング カートと同様です。そこに。

4

4 に答える 4

0

コレクションは動的に並べ替えられるのではなく、事前に並べ替えられるため、ページの読み込みが速くなります。

同じ商品で、並べ替えが異なる複数のコレクションを作成できます。次に、ユーザー入力に基づいて関連するコレクションに移動できます。

于 2012-11-02T14:44:27.073 に答える
0

最近、ストアフロントでコレクションを動的に並べ替える機能が追加されました (バックエンドでコレクションを 1 つの順序でのみ並べ替えることができるようになる前に.

ドキュメント: http://docs.shopify.com/manual/configuration/store-customization/advanced-navigation/add-a-reorder-drop-down-menu-to-a-collection-page

元コード: https://gist.github.com/carolineschnapp/11352987

于 2014-05-08T15:44:41.447 に答える
0

アプリの支払いを回避したい場合 (必要な選択の数だけ各コレクションを複製する場合と複製しない場合があります)、以下のコードを使用 / 適応させます。

  <script>
    // jquery is already running on the site, so we use it to check the document is ready
    $(document).ready(function() {
        // Identify a Select Option from the value in the URL query text
        // Where this exists as an Option Value, add the 'selected' attribute to the Option
        // This ensures that when the page reloads the current option will be showing
        $("#selectSort option[value='{{collection.sort_by}}']").attr('selected', true);
    });
  </script>

  <div>
    <!-- 
    The Select Tag watches for a change, then pushes a new window.location using the value
    of the Option selected by the user
    -->
    <select id="selectSort" onchange='window.location="{{ collection.url }}?sort_by=" + this.value'>
      <option value="price-ascending">Price (lowest first)</option>
      <option value="price-descending">Price (Highest first)</option>
      <option value="title-ascending">A-Z</option>
      <option value="title-descending">Z-A</option>
      <option value="created-descending">Latest Addition</option>
      <option value="best-selling">Most Popular</option>
    </select>
  </div>
于 2014-05-20T13:01:23.273 に答える