0

I need to update the Price for all configurable products in the database but I am not sure what table or column to use within my query.

I am almost there as I can enter the lowest priced simple product Price for all configurable products in a new table I created but what I need is to update the current price of the configurable products.

require_once('app/Mage.php');
umask(0);
Mage::app();

include 'pathtocredentials.php';
$con = mysqli_connect  ($host, $username, $password, $dbname);

$configurable = Mage::getResourceModel('catalog/product_collection')->addAttributeToFilter('type_id', array('eq' => 'configurable'));

foreach ($configurable as $_configurableproduct) {

    $product = Mage::getModel('catalog/product')->load($_configurableproduct->getId());
    $id = $product->getId();
    $price = $product->getFinalprice();

mysqli_query($con,"UPDATE some_table SET some_column=$price WHERE id=$id";

}

mysqli_close($con);

1 Answer 1

0

I am unable to comment currently, however I can guide you:

Price is stored on the catalog_product_entity_decimal table linked to product ID (called entity_id)

So your query would now be

mysqli_query($con,"UPDATE catalog_product_entity_decimal SET value=$price WHERE entity_id=$id");

You might want to try and see if this works for you.

Note: Please take database backup before doing this.

2
  • I will try this soon thanks. I'm curious. Would it be "WHERE entity_id=$id" ? Commented Feb 3, 2016 at 8:17
  • That's right. Updated my answer.
    – Shivani
    Commented Feb 3, 2016 at 8:37

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.