0
votes

I am inserting data into the addresses of the customers in magento, I am able to add all the fields except the street field, would anyone know why? The data is not entered, does not show any error, the other fields are all text or select, so they will normally, this field has only one label, I get the database label, I give a var_dump and it returns me the addresses, but does not add, I think I'm wrong on setStreet1, setStreet2, setStreet3, setStreet4.

Would I have to enter these values ​​in any different way? How do I set this data in the database? Would I have set them differently? I put the data in the bank normally by its name, first_name = Firstname, and here I am trying to do the same thing, but in street it is different is like [street] [0], street. Other data are like [first_name], [last_name]. Because he opened another [] would I have to add it in another way?

The way I pull this information is this way

'rua'=>$usuario_loaded->getStreet1(), 'numero'=>$usuario_loaded->getStreet2(), 'complemento'=>$usuario_loaded->getStreet3(), 'bairro'=>$usuario_loaded->getStreet4()

                    $i = 1;

                    $link = mysqli_connect('localhost','root','','x');
                    $link->set_charset("utf8");
                    $query = "SELECT * from endereços";
                    $select = mysqli_query($link, $query);
                    foreach ($select as $key => $selects) {
                    $link = mysqli_connect('localhost','root','','x');
                    $link->set_charset("utf8");
                    $query = "SELECT * from endereços";
                    $select = mysqli_query($link, $query);
                    while($row = mysqli_fetch_array($select)){
                    $teste = array(
                            $endereço_id = $row['endereço_id'],
                            $nome = $row['nome'],
                            $assinatura = $row['assinatura'],
                            $sobrenome = $row['sobrenome'],
                            $rua = $row['rua'],
                            $numero = $row['numero'],
                            $complemento = $row['complemento'],
                            $bairro = $row['bairro'],
                            $cidade = $row['cidade'],
                            $país = $row['país'],
                            $estado = $row['estado'],
                            $cep = $row['cep'],
                            $telefone = $row['telefone'],
                            );

                            var_dump($teste);

                            $customer = Mage::getModel("customer/address");
                            $customer   ->setId($endereço_id)
                                        ->setFirstname($nome)
                                        ->setMiddlename($assinatura)
                                        ->setLastname($sobrenome)
                                        ->setStreet1($rua)
                                        ->setStreet2($numero)
                                        ->setStreet3($complemento)
                                        ->setStreet4($bairro)
                                        ->setCity($cidade)
                                        ->setCountryId($país)
                                        ->setRegionId($estado)
                                        ->setPostcode($cep)
                                        ->setTelephone($telefone)

                            try{
                                    $customer->save();
                                }
                                catch (Exception $e) {
                                    Zend_Debug::dump($e->getMessage());
                                }
                            }
                    }

Image

enter image description here

1
Without knowing the structure of the database, we can't help. It's most likely that Street0 and the others are not setup as VARCHAR or TEXT or setup as a short length - Forbs
I was able to insert date in the first field, putting only -> setStreet, but in others I could not, exactly magento has a very difficult database. - Gustavo Souza
In the bank is saved as text, I just see here, it is saved in a single value the 4 fields. - Gustavo Souza
I'll update the question with an image of the bank. - Gustavo Souza

1 Answers

0
votes

I did, I simply had to add the data with an array. Changing only this line

-> setStreet (array ($rua, $numero, $complemento, $bairro))