Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Magento SQL
 
Alecs00
Member
 
Total Posts:  73
Joined:  2011-05-03
 

Salutare,

Greutatea produselor e trecuta intr-un atribut numit “greutate”, cum pot sa iau toate valorile din greutate si sa le mut in atributul standard “weight”.

SELECT value FROM `catalog_product_entity_decimalWHERE attribute_id=
(
SELECT attribute_id FROM eav_attribute
WHERE attribute_code
="weight" AND entity_type_id=10
)
Showing rows 0 - 29 ( 99 total, Query took 0.0015 sec)

SELECT value FROM `catalog_product_entity_varchar
WHERE attribute_id=(SELECT attribute_id FROM eav_attribute WHERE attribute_code="greutate" AND entity_type_id=10)

Showing rows 0 - 29 ( 5,671 total, Query took 0.0015 sec)

UPDATE catalog_product_entity_decimal SET value value + ( "Valoare atribului greutate")
WHERE attribute_id= (SELECT attribute_id FROM eav_attribute
WHERE attribute_code
="weight" AND entity_type_id=10);

Cum pot sa unesc (sum) cele doua atribute si sa salvez resultatul in weight ?

 
Magento Community Magento Community
Magento Community
Magento Community
 
bitstream
Member
 
Avatar
Total Posts:  45
Joined:  2008-04-10
 

Fa un mic script php.

faci un connect la db-ul de magento

SELECT attribute_id FROM eav_attribute WHERE attribute_code="weight" AND entity_type_id=10
=> 100

SELECT attribute_id FROM eav_attribute WHERE attribute_code="greutate" AND entity_type_id=10
=>69

$sql "SELECT * FROM `catalog_product_entity_decimal` WHERE attribute_id = 69";

$result mysql_query($sql);


while (
$row mysql_fetch_assoc($result)) {

    $new_val 
$row['value']
    
    $sql 
"UPDATE `catalog_product_entity_decimal` SET `value` = `value` 
        WHERE `attribute_id` = 100 AND `entity_id` = 
$row['entity_id']
    "
;
    
mysql_query($sql);


}

E doar un draft, verifici sa fie ok phpul.

 
Magento Community Magento Community
Magento Community
Magento Community
 
Alecs00
Member
 
Total Posts:  73
Joined:  2011-05-03
 

Salut, am incercat cu codul php dar am o eroare pe undeva si nu imi dau seama:

<?php
$user
="user";
$pass="pass";
$database="database";
$con mysql_connect("localhost"$user$pass)
or die (
'Couldnt connect to server');
mysql_select_db($database,$con)
or die(
'could not connect to db');


$sql "SELECT * FROM `catalog_product_entity_varchar` WHERE `attribute_id`=986";
$result mysql_query($sql);

while (
$row mysql_fetch_assoc($result)) {
    $new_id 
$row['entity_id'];
    
$new_val $row['value'];
    if (
$new_val==0) : $new_val 1;
    endif;
    
$query "UPDATE `catalog_product_entity_decimal` SET `value` = '.$new_val' WHERE `attribute_id` = 101 AND `entity_id` = '.$new_id'";
mysql_query($query);     
print 
mysql_affected_rows();
 
echo 
$new_val  $new_id  <br>  ";
    
}  

?>
Se conecteaza la baza de date, imi afiseaza valorile pe care le cer dar nu le scrie inapoi
Practic trebuie sa ia valorea din “value” din tabelul “catalog_product_entity_varchar” unde id - 986 - e id-ul atributului greutate
si sa o scrie in “value” din “tabelul catalog_product_entity_decimal”

Codul afiseaza :
0 7 984
0 1 987
0 1 991
0 1 990
0 1 1014
0 5.3 953
0 5.2 954
0 5.5 959
0 1.80 977
..................

0 - print mysql_affected_rows(); ( -1 - eroare mysql, 0 - nimic ( nu scrie ) ..1 pt insert ...2 pt update )
7 - $new_val = $row[’value’]; - valoare din greutate
984 - $new_id = $row[’entity_id’]; - entity_id

Ma poate ajuta cineva ?
Va multumesc anticipat smile

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top