Кемеровские программисты php общаются здесь
Anonymous
Как сгруппировать массив по атрибуту [дубликат]
Сообщение
Anonymous » 23 окт 2024, 09:46
Мне нужно будет создать массив, группирующий комбинации продуктов, доступных в Prestashop.
Начальный массив следующий:
Код: Выделить всё
Array (
[id_product_attribute] => 66
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] =>
[upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000
[quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 1
[is_color_group] => 0
[group_name] => Dimensione
[attribute_name] => XS
[id_attribute] => 26
)
Array (
[id_product_attribute] => 66
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] =>
[upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000
[quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 2
[is_color_group] => 0
[group_name] => Colore
[attribute_name] => Cammello
[id_attribute] => 12
)
Array (
[id_product_attribute] => 67
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] =>
[upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000 [quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 1
[is_color_group] => 0
[group_name] => Dimensione
[attribute_name] => L
[id_attribute] => 3
)
Array (
[id_product_attribute] => 67
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] =>
[upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000
[quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 2
[is_color_group] => 0
[group_name] => Colore
[attribute_name] => Cammello
[id_attribute] => 12
)
Array (
[id_product_attribute] => 68
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] =>
[upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000
[quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 2
[is_color_group] => 0
[group_name] => Colore
[attribute_name] => Verde
[id_attribute] => 15
)
Array (
[id_product_attribute] => 68
[id_product] => 2
[reference] =>
[supplier_reference] =>
[location] =>
[ean13] =>
[isbn] => [upc] =>
[wholesale_price] => 0.000000
[price] => 0.000000
[ecotax] => 0.000000
[quantity] => 0
[weight] => 0.000000
[unit_price_impact] => 0.000000
[default_on] =>
[minimal_quantity] => 1
[low_stock_threshold] =>
[low_stock_alert] => 0
[available_date] => 0000-00-00
[id_shop] => 1
[id_attribute_group] => 5
[is_color_group] => 0
[group_name] => Dimensione
[attribute_name] => XL
[id_attribute] => 27
)
Я хотел бы получить что-то вроде этого:
Код: Выделить всё
Array
(
[0] => Array
(
[color] => Cammello
[size] => XS | L
)
[1] => Array
(
[color] => Verde
[size] => XL
)
)
По сути, мне нужно получить все комбинации товаров магазина одежды, созданные с помощью Prestahop. Конечная цель — создать XML-файл со всеми данными о продукте, где каждый узел представляет собой вариант продукта.
Подробнее здесь:
https://stackoverflow.com/questions/791 ... -attribute
1729666016
Anonymous
Мне нужно будет создать массив, группирующий комбинации продуктов, доступных в Prestashop. Начальный массив следующий: [code]Array ( [id_product_attribute] => 66 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 1 [is_color_group] => 0 [group_name] => Dimensione [attribute_name] => XS [id_attribute] => 26 ) Array ( [id_product_attribute] => 66 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 2 [is_color_group] => 0 [group_name] => Colore [attribute_name] => Cammello [id_attribute] => 12 ) Array ( [id_product_attribute] => 67 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 1 [is_color_group] => 0 [group_name] => Dimensione [attribute_name] => L [id_attribute] => 3 ) Array ( [id_product_attribute] => 67 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 2 [is_color_group] => 0 [group_name] => Colore [attribute_name] => Cammello [id_attribute] => 12 ) Array ( [id_product_attribute] => 68 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 2 [is_color_group] => 0 [group_name] => Colore [attribute_name] => Verde [id_attribute] => 15 ) Array ( [id_product_attribute] => 68 [id_product] => 2 [reference] => [supplier_reference] => [location] => [ean13] => [isbn] => [upc] => [wholesale_price] => 0.000000 [price] => 0.000000 [ecotax] => 0.000000 [quantity] => 0 [weight] => 0.000000 [unit_price_impact] => 0.000000 [default_on] => [minimal_quantity] => 1 [low_stock_threshold] => [low_stock_alert] => 0 [available_date] => 0000-00-00 [id_shop] => 1 [id_attribute_group] => 5 [is_color_group] => 0 [group_name] => Dimensione [attribute_name] => XL [id_attribute] => 27 ) [/code] Я хотел бы получить что-то вроде этого: [code]Array ( [0] => Array ( [color] => Cammello [size] => XS | L ) [1] => Array ( [color] => Verde [size] => XL ) ) [/code] По сути, мне нужно получить все комбинации товаров магазина одежды, созданные с помощью Prestahop. Конечная цель — создать XML-файл со всеми данными о продукте, где каждый узел представляет собой вариант продукта. Подробнее здесь: [url]https://stackoverflow.com/questions/79116677/how-to-group-array-by-attribute[/url]