Cannot add attribute programatically

Permalink 1 user found helpful
Hi
I'm trying to import a CSV file to add pages as well as some attributes. The page adds correctly but the attributes doesn't. Here is my code:

public function add() {
      if ($this->isPost()) {
         $this->validate();
         //echo 'Im here'; die;
         if(!$this->error->has()) {
            Loader::model('collection_types');
            $path = "/companies";
            $newPage = Page::getByPath($path);
            $data = array();
            //get the csv file 
            $file = $_FILES['ronyd_csv']['tmp_name'];
            //echo '<pre>'; print_r($file);
            $handle = fopen($file,"r"); 
            //loop through the csv file and insert into database 
            do{


Am I doing anything wrong?

Rony

ronyDdeveloper
 
Tao replied on at Permalink Reply
Tao
Did you want to set attribute to parent page?

I think...
$parentPage =  Page::getByPath("/companies");
$newPage = $parentPage->add($ct,$data);
$newpage->setAttribute(...

Do you want like this?
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
No I want it to set on all child pages..
Tao replied on at Permalink Best Answer Reply
Tao
I think your code is set attribute to parent page.
ronyDdeveloper replied on at Permalink Reply
ronyDdeveloper
Ohh Ohh Ohh.... :) I got it. Fully my mistake. Thanks for pointing that.

Rony
Tao replied on at Permalink Reply
Tao
Sorry, My English is not good.

Good luck!
Tao replied on at Permalink Reply
Tao
Sorry, My English is not good.

Good luck!