magento sort array product IDs

$attributes = Mage::getSingleton(‘catalog/config‘)->getProductAttributes();
$collection = Mage::getModel(‘catalog/product‘)
	->getCollection()
	->addAttributeToFilter(‘entity_id‘, array(‘in‘ => $productIds))
	->addAttributeToSelect($attributes);

$collection->getSelect()->order(new Zend_Db_Expr(‘FIELD(e.entity_id, ‘ . implode(‘,‘, $productIds).‘)‘));
时间: 2024-10-24 15:17:27

magento sort array product IDs的相关文章

[leetcode][easy][Array][905][Sort Array By Parity]

Sort Array By Parity 题目链接 题目描述 给定一个非负整型数组A,返回一个数组,数组中靠前的位置是A中的偶数,靠后的位置是A中的奇数.偶数范围内顺序不限,奇数也是. 约定 1 <= A.length <= 5000 0 <= A[i] <= 5000 示例 Input: [3,1,2,4] Output: [2,4,3,1] The outputs [4,2,3,1], [2,4,1,3], and [4,2,1,3] would also be accepte

LeetCode 905. Sort Array By Parity

905. Sort Array By Parity Given an array A of non-negative integers, return an array consisting of all the even elements of A, followed by all the odd elements of A. You may return any answer array that satisfies this condition. Example 1: Input: [3,

905. Sort Array By Parity

题目来源: https://leetcode.com/problems/sort-array-by-parity/ 自我感觉难度/真实难度: easy/easy 题意: 把列表里的偶数放在前面,奇数放在后面 分析: 自己的代码: class Solution(object): def sortArrayByParity(self, A): """ :type A: List[int] :rtype: List[int] """ c=[] b=[]

Sort Array By Parity II LT922

Given an array A of non-negative integers, half of the integers in A are odd, and half of the integers are even. Sort the array so that whenever A[i] is odd, i is odd; and whenever A[i] is even, i is even. You may return any answer array that satisfi

【LEETCODE】41、905. Sort Array By Parity

package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: SortArrayByParity * @Author: xiaof * @Description: 905. Sort Array By Parity * Given an array A of non-negative integers, return an array

【LEETCODE】42、922. Sort Array By Parity II

package y2019.Algorithm.array; /** * @ProjectName: cutter-point * @Package: y2019.Algorithm.array * @ClassName: SortArrayByParityII * @Author: xiaof * @Description: 922. Sort Array By Parity II * Given an array A of non-negative integers, half of the

Relative Sort Array

Relative Sort Array Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2. Elements that don't

magento related/upsell product 及产品/分类调用

catalog/product调用 $product_model = Mage::getModel('catalog/product'); $product = $product_model->load($product_id); //可通过product_id 获取 product_name$product->getName(); $product_url = $product->getUrlModel()->getUrl($product, array('_ignore_cat

Sort Array

各种 Sort 算法,包括 Quick Sort, Merge Sort, Heap Sort, Count Sort 1 package Sort; 2 3 public class Sort { 4 /* 5 * Quick Sort 6 * Time : O(n log n) 7 * Space : O(log n) -- stack frame 8 */ 9 private void quickSort(int[] arr) { 10 if (arr == null || arr.len