Productlist with all possible configurations
-
16-12-2020 - |
質問
We are looking for a way to get a list with all possible product configurations per product and its associated price, including delivery. If the same product has a different price or options it has to be registered as a new product.
e.g.
productName, price, sku, entityId, array(options, optionIds), delivery
Flyer, 1.99, flyer, 1, [[small, 1], [colorful, 2]], normalDelivery
Flyer, 2.99, flyer, 1, [[big, 3], [colorful, 2]], normalDelivery
Flyer, 3.99, flyer, 1, [[small, 1], [colorful, 2]], fastDelivery
Flyer, 4.99, flyer, 1, [[big, 3], [colorful, 2]], fastDelivery
We tried the following code but it doesn’t contain all possible configurations and their associated price like shown in the example above:
<?php $collection = Mage::getModel('catalog/product')->getCollection()->addAttributeToSelect('*');
Thanks in Advance.
解決
With getUsedProducts
function, an example code part may look like this:
$product = Mage::getModel('catalog/product')->load(%PRODUCT_ID%);
$childProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
foreach($childProducts as $child) {
print_r($child->getWhateveryouwant());
}