Is it possible to select entires based on a custom channel field e.g. where product_original_price!=”“
{exp:channel:entries channel="products" category="1" status="open" orderby="product_price|title" sort="asc|asc" paginate="both" limit="9" product_original_price!=""}I want to query products to only show products that meet certain criteria such as if they have been discounted or are between a price range.
I got this working to a point by doing the check after i had selected the entries using the channel entries tag. e.g. if product_original_price!=”” then show the product. However, this messed up the pagination.
{exp:channel:entries channel="products" category="1" status="open" orderby="product_price|title" sort="asc|asc" paginate="both" limit="9"}
{if product_original_price && product_original_price > product_price}
<div class="{switch="product|product|product_right"}">
<a href="http://{site_url}{segment_1}/{url_title}" title="{title}">{product_thumbnail}</a>
{title}
<span class="price">{product_price}</span>
<div class="was">Was: {product_original_price}</div>
</div>
{/if}
{paginate}
<div ></div><!-- END clear -->
<div class="product_bar">
Page {current_page} of {total_pages}
{pagination_links}
{previous_page}
<a href="http://{pagination_url}" class="page-previous">< Prev</a>
{/previous_page}
{first_page}
<a href="http://{pagination_url}" class="page-first">1</a>
{/first_page}
{page}
<a href="http://{pagination_url}" class="page-{pagination_page_number}">{pagination_page_number}</a>
{/page}
{last_page}
<a href="http://{pagination_url}" class="page-first">{total_pages}</a>
{/last_page}
{next_page}
<a href="http://{pagination_url}" class="page-next">Next ></a>
{/next_page}
{/pagination_links}
<a href="http://{site_url}{segment_1}/all" title="Show all products" class="view_all">View All</a>
</div><!-- END .product_bar-->
{/paginate}
{/exp:channel:entries}If this is not possible with the channel entries tag is there another way to achieve this, maybe with SQL?