I'm importing configurable items with Magmi 0.7.23 and I want the price of the options to pull from the price of the underlying simple item.

In the Magmi documentation, they say

Set price to 12 for option value L & 15 for option value XL for attribute size

I cannot build my spreadsheet this way without manually typing all these values in and for the same price, I can go into all the config items in the Magento admin and change the price manually.

1) Is there a way to "force" Magmi to use the price of the simple product?

2) I know there's an extension to use the underlying simple pricing, but I'd rather not use an extension, I would prefer building the product properly.

3) Can I write a script to loop through the configurable products and for each simple product grab it's price and set it as the price for that configuration?

2 Answers 2


This should do what you are looking for

require_once 'app/Mage.php';

$configurableIds = Mage::getResourceModel('catalog/product_collection')->addFieldToFilter('type_id', 'configurable')->getAllIds();
foreach ($configurableIds as $id) 
    $product = Mage::getModel('catalog/product')->load($id); 
    $configurableAttributesData = $product->getTypeInstance()->getConfigurableAttributesAsArray();
    $simpleProducts = Mage::getModel('catalog/product_type_configurable')->getUsedProducts(null,$product);
    foreach ($simpleProducts as $prod) {
    foreach ($configurableAttributesData as $k1 => $att) {
    foreach ($att["values"] as $k2=>$opt) {
    if($opt["value_index"] == $prod->getData($att["attribute_code"])){
        $configurableAttributesData[$k1]["values"][$k2]["pricing_value"] = $prod->getPrice() - $product->getPrice();
  1. probably not. You could possibly write a preprocessing script that converts your CSV file to the right format before passing it to Magmi. This would be the most performant way to deal with the issue.

  2. good decision

  3. that's the easier solution. It would be a PHP script similar to this:

    require_once 'magento/app/Mage.php';
    $configurableProductIds = Mage::getResourceModel('catalog/product_collection')->addFieldToFilter('type_id', 'configurable')->getAllIds();
    $configurableProductType = Mage::getModel('catalog/product_type_configurable');
    foreach ($configurableProductIds as $id) 
        $configurableProduct = Mage::getModel('catalog/product')->setId($id);
        $simpleProducts = $configurableProductType->getUsedProducts(null, $product);
        // TODO: get price for each simple product
        // TODO: assign prices to options of configurable product
        // TODO: save configurable product

    I wrote this from top of my head and left the parts blank where you save the prices. I would have to look up the details, and you probably can do that by yourself. What is important here, that you don't load a whole collection of all configurable products at once, only the IDs.

  • thanks @fschmengler - can you fill in those last three lines? i couldn't figure it out
    – Haim
    Dec 20, 2016 at 13:55
  • @Haim really? Have you even tried or looked on Magento SE? Dec 22, 2016 at 8:12
  • 1
    @JulienLachal here's the part that I need help with // TODO: assign prices to options of configurable product
    – Haim
    Dec 22, 2016 at 14:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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