Skip to main content
Tweeted twitter.com/#!/StackMagento/status/627627632969031680
added 30 characters in body
Source Link
ND17
  • 5.2k
  • 9
  • 50
  • 78

I want to add samples in downloadable product programmatically.

I am trying this

 $samplefiles[] = array(
                    'file' => '/u/n/untitled_1.png',
                    'name' => 'Untitled.png',
                    'size' => 4672,
                    'status' => 'new'
            );
 $sampleModel = Mage::getModel('downloadable/sample')->setData(array(
                    'product_id' => $product->getId(),
                    'sort_order' => 0,
                    'sample_url' => '',
                    'sample_file' => json_encode($samplefiles),
                    'sample_type' => 'url',
            ));
            $sampleModel->save();

But its not working..And how to save sample title

I want to add samples in downloadable product programmatically.

I am trying this

 $samplefiles[] = array(
                    'file' => '/u/n/untitled_1.png',
                    'name' => 'Untitled.png',
                    'size' => 4672,
                    'status' => 'new'
            );
 $sampleModel = Mage::getModel('downloadable/sample')->setData(array(
                    'product_id' => $product->getId(),
                    'sort_order' => 0,
                    'sample_url' => '',
                    'sample_file' => json_encode($samplefiles),
                    'sample_type' => 'url',
            ));
            $sampleModel->save();

But its not working..

I want to add samples in downloadable product programmatically.

I am trying this

 $samplefiles[] = array(
                    'file' => '/u/n/untitled_1.png',
                    'name' => 'Untitled.png',
                    'size' => 4672,
                    'status' => 'new'
            );
 $sampleModel = Mage::getModel('downloadable/sample')->setData(array(
                    'product_id' => $product->getId(),
                    'sort_order' => 0,
                    'sample_url' => '',
                    'sample_file' => json_encode($samplefiles),
                    'sample_type' => 'url',
            ));
            $sampleModel->save();

But its not working..And how to save sample title

Source Link
ND17
  • 5.2k
  • 9
  • 50
  • 78

How to save samples in downloadable product programmatically?

I want to add samples in downloadable product programmatically.

I am trying this

 $samplefiles[] = array(
                    'file' => '/u/n/untitled_1.png',
                    'name' => 'Untitled.png',
                    'size' => 4672,
                    'status' => 'new'
            );
 $sampleModel = Mage::getModel('downloadable/sample')->setData(array(
                    'product_id' => $product->getId(),
                    'sort_order' => 0,
                    'sample_url' => '',
                    'sample_file' => json_encode($samplefiles),
                    'sample_type' => 'url',
            ));
            $sampleModel->save();

But its not working..