Blog Hero Image

Algorithmic Merchandising: Sorting Collections by Net Profit (COGS), Not Just Revenue

7 Min Read

Web Development
Author

Mayursinh Jadeja

Feb 5, 2026

LinkedInFacebookTwitter

Use AI to summarize this article

In this blog post

    Introduction

    If you visit 90% of Shopify Plus stores today and click on a Collection page, the default sort order is almost always the same: "Best Selling."

    On the surface, this seems logical. Give the people what they want. Show the popular items first.

    But if you look at this through the lens of a CFO, "Best Selling" is often a financial disaster.

    The Scenario:

    • Item A (Best Seller): A $20 t-shirt with a $15 cost basis (25% margin).
    • Item B (3rd Best Seller): A $100 jacket with a $40 cost basis (60% margin).

    The Problem: By forcing the t-shirt to the top of the grid (Positions 1-4), you are dedicating your most valuable digital real estate to your least profitable SKUs. You are actively training your algorithm to prioritize Revenue (Top Line) over Profit (Bottom Line).

    In 2026, with ad costs rising and capital becoming expensive, "Growth at all costs" is dead. The new mandate is "Profitable Growth."

    At Redlio Designs, we help scaling brands switch from "Manual Merchandising" (drag-and-drop) to "Algorithmic Merchandising." We write code that dynamically re-sorts your collections based on Net Margin Contribution, ensuring that the products occupying the "Golden Triangle" (Top Left) are the ones that actually fund your business.

    1. The "Best Selling" Trap

    "Best Selling" is a vanity metric. It measures volume, not value.

    When you sort by volume, you create a self-fulfilling prophecy:

    1. Item A is cheap and sells well.
    2. The algorithm puts Item A at the top.
    3. Traffic sees Item A first and buys it.
    4. Item A retains the top spot forever.

    Meanwhile, your high-margin innovations (Item B) are buried on Row 4. They never get the impressions needed to gain velocity. You end up with a high-revenue store that barely breaks even.

    The Redlio Strategy: We don't remove "Best Selling." We create a "Smart Sort"—a weighted algorithm that balances Popularity with Profitability.

    2. The Data Layer: Ingesting COGS

    To sort by profit, Shopify needs to know your profit.

    Most brands have this data, but it is locked in their ERP (NetSuite, Cin7) or a spreadsheet. It rarely makes it into Shopify's logic layer.

    Step 1: The Cost Metafield

    We utilize the native inventory_item.cost field in Shopify, but often, this isn't enough for complex use cases. We recommend creating custom Profit Metafields on the variant level:

    • variant.metafields.finance.cogs: $15.00
    • variant.metafields.finance.margin_dollars: $35.00
    • variant.metafields.finance.margin_percent: 0.70

    Step 2: The Sync

    We build a custom middleware script (using the Shopify Admin API) that runs every night. It pulls the latest landed cost from your ERP and updates these Metafields. This ensures that if your shipping tariffs go up, your margin calculation adjusts automatically.

    3. The Algorithm: Developing the "Profit Score"

    Once the data is in Shopify, we need a formula. We don't just sort by "Highest Price" (which ignores cost) or "Highest Margin %" (which might promote a $5 item with 90% margin).

    We calculate a Weighted Profit Score.

    The Formula:

    Score = (Sales Velocity * 0.4) + (Margin $ * 0.6)

    • Sales Velocity: How many units sold in the last 7 days? (Normalized 0-100).
    • Margin $: How many profit dollars does one unit generate? (Normalized 0-100).

    The Result:

    • A cheap, fast-moving item gets a score of 60.
    • A moderately fast-moving, high-margin jacket gets a score of 85.

    The Jacket wins Position 1.

    This is "Revenue Engineering." We are mathematically designing the collection page to maximize EBITDA, not just Gross Merchandise Value (GMV).

    4. Execution: API Automation Strategy

    Historically, merchandising required a human to drag-and-drop products in the admin. This is unscalable for catalogs with 5,000 SKUs.

    We automate this using the Shopify Admin API to Programmatically Merchandize.

    The Workflow:

    1. Calculation: Our server calculates the "Profit Score" for every product nightly.
    2. The Re-Order: We use the collectionReorderProducts mutation in the Shopify API.
    3. The Override: We programmatically update the collection's "Manual Sort Order" based on our algorithm.

    Visual Merchandising Rules: We can also utilize the Shopify Search & Discovery API to inject "Boost" rules.

    • Rule: "Always Boost products with margin_percent > 0.6."
    • Rule: "If a product is < 3 units in stock, demote it to the bottom" (regardless of margin). We don't want to waste prime real estate on broken sizes.

    5. The "Inventory Velocity" Multiplier

    Profit isn't just about the margin on one sale. It is about Inventory Turnover.

    Sitting on dead stock costs money (storage fees, capital interest). Sometimes, the "Most Profitable" move is to clear old inventory quickly to free up cash flow.

    The "Flush" Algorithm: We can introduce an age_in_days variable to our score.

    • If a product has been in the warehouse > 90 days, we artificially boost its visibility score.
    • We expose it to traffic before marking it down.

    This allows you to clear stale inventory at Full Price simply by improving its visibility, rather than slashing the price and destroying the margin.

    6. The Redlio Merchandising Audit

    How do we implement this? We start with a data audit.

    1. Margin Analysis: We export your last 6 months of sales. We calculate what your profit would have been if you had prioritized high-margin items. The "Opportunity Cost" is usually shocking (often +15% Net Profit).
    2. Data Integrity Check: Do you actually have accurate COGS in Shopify? Usually, 30% of SKUs are missing cost data. We fix the data pipeline first.
    3. Algorithm Design: We workshop the weighting with your CFO. Does she care more about clearing old stock or maximizing pure profit dollars? We tune the math to her goals.

    Conclusion

    In the early days of DTC, "Top Line Revenue" was the only metric VCs cared about. You could lose money on every order, as long as you were growing.

    Those days are over.

    Your website is your primary salesperson. If a human salesperson kept recommending the cheapest items to your best customers, you would fire them. Yet, that is exactly what your "Best Selling" sort order is doing.

    Algorithmic Merchandising aligns your storefront behavior with your business goals. It turns your collection pages into profit-generating machines.

    At Redlio Designs, we don't just make your store look good. We make your P&L look good.

    Is your merchandising strategy leaking profit? Contact Redlio Designs today for a comprehensive Merchandising Audit. Let’s turn your collection pages into profit-generating machines.

    Frequently Asked Question

    Does Shopify allow sorting by custom logic natively? 

    Native Shopify sorting is limited (Price, Date, Best Selling). However, utilizing Search & Discovery features or the Admin API, we can force a "Manual Sort Order" that follows our custom algorithm. This allows us to inject sophisticated logic (like COGS awareness) that the native dropdowns do not support.

    Can we A/B test this sort order? 

    Yes. We highly recommend it. We can use a tool like Intelligems or a custom split-test to show 50% of users the "Best Selling" sort and 50% the "Profit Score" sort. We measure the Revenue Per Session and Profit Per Session. Typically, Profit Per Session increases by 10-15% with the new logic.

    Does this affect SEO rankings? 

    No. The actual URL structure and content of the product pages remain the same. We are simply changing the order in which they appear on the collection page. In fact, by cycling products more dynamically, you may signal "freshness" to Google, which can help crawl rates.

    What if my COGS change frequently? 

    Our integration is dynamic. If your ERP updates the Landed Cost due to a change in shipping tariffs, our middleware detects the change during the nightly sync, recalculates the margin, updates the score, and re-shuffles the collection automatically. Your merchandising is always in sync with your finance team.

    Scalable Web Solutions

    Future-proof your website with our custom development solutions.

    Get a Free Quote
    Redlio Designs Logo