1

I'm attempting to retrieve the entire column of both kit_sku and related_sku. However, it doesn't seem to parse correctly. Both $componentSkus and $componentRequiredQuantity are returning identical arrays.

        $kitCollection = Mage::getModel('path/path')
            ->getCollection()
            ->addFieldToFilter('kit_sku', $sku)
            ->setOrder('related_sku', 'ASC');

        $select = $kitCollection->getSelect();

        $select->reset(Zend_Db_Select::COLUMNS)
            ->distinct()
            ->columns('related_sku')
            ->columns('required_quantity');

        $connection = $kitCollection->getConnection();

        $componentSkus = $connection->fetchCol($select, 0);

        $componentRequiredQuantity = $connection->fetchCol($select, 1);
2

According to http://framework.zend.com/manual/1.12/en/zend.db.adapter.html fetchCol will only return the first column.

Your best bet will be to use fetchPairs and then use PHP's array_keys to get the first column and array_values for second.

Or do 2 separate queries

0

I do not know of any fetchCol() implementation that takes the column index as second argument. It always

Fetches the first column of all SQL result rows as an array.

You should have a look at the database adapter class and find another fetch*() method appropriate to your needs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.