Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:19:06+00:00 2026-06-05T14:19:06+00:00

Say I have the following entity called inventory: I would like to know if

  • 0

Say I have the following entity called inventory:

enter image description here

I would like to know if there are database, sql or magento actions or any other methods to produce:

enter image description here

I have solved this by iterating through the entire collection and inserting into a temporary table : i.e

$inventorySet = Mage::getModel('custom/module')->getCollection(*);
foreach($inventorySet as $item)
{
    $this->insertItem($item->getSku());
}

}

public function insertItem($sku)
{
    //insert sku if it does not exist in the temp set
    // if it does exists add one to the QTY field
}

I can then retrieve what I want. I don’t see an issue with it, but my entity is a lot larger than the example as well as the set of data containing anything between 2000 – 15 000 rows. is there not a more efficient way of doing this?

EDIT: In words, I would like to search the collection for occurrences of the “sku” field and return an array of unique sku’s and the number of times it was found in the initial collection.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:19:07+00:00Added an answer on June 5, 2026 at 2:19 pm

    To get a particular set of column values from a collection you can use the getColumnValues() method.

    For example, using a Magento product collection, this would return an array containing the sku attribute value for every product:

    $collection = Mage::getResourceModel('catalog/product_collection')
        ->addAttributeToSelect('sku');
    
    $skus = $collection->getColumnValues('sku');
    

    Finally, to answer the second part of your question, to count the occurence of each unique value:

    array_count_values($skus);

    This will give you a nice associative array of sku => occurrence count.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have the following tables setup in SQL Server (2008) Is there
Say, I have following entities: @Entity public class A { @Id @GeneratedValue private Long
Let's say I have following table like this <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have the following class structure: /** Boring bits snipped */ @Entity
Let's say I have an entity in 3d space and I know its position
Say I have the following entity classes: public class Order { public int OrderID
Lets say I have the following in my top level .vhd file entity toplevel
Lets say you have the following entities in your database: Image http://lh6.ggpht.com/_UpGtM3B8h1U/Sa7SqfWmgDI/AAAAAAAAAHE/epqtm7EnoFg/test.gif You want
Lets say we have the following entities. Entity A Entity B Entity C The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.