0

We have button "create" and onclick "Create" button, it will create product programmatically and assign custom image to that product.

app/design/frontend/rwd/Theme3/template/aitcg - js_styles1.phtml

<script>

var Aitcg_View_Abstract = Class.create(
{

_getControlPanelHtml: function()
    {
        if (this.config.editorEnabled) {
            return '<div>' +
                '<button  onclick="return setproductlogin(\'<?php echo Mage::registry("current_product")->getId()?>\', event);setrequestlogin();"  id="submit-editorApply-{{rand}}">create</button>' +
                '<button>reset</button>' +
                '</div>';
        }
        return '';
    },

initObservers: function() 
      { 
        if (this.config.editorEnabled) {  
           $('submit-editorApply-' + this.config.rand).observe('click', this.createDesignBut.bindAsEventListener(this));           
         } 
       }, 

createDesignBut: function(event) 
        { 
          Event.stop(event); 
          this.option.apply(); 
        },     
}); 

</script>

we are trying to do the same [ create product programtically and assign custom image ] , once we submit form by clicking "login button". here we are creating product sucessfully, but custom image is not saving in server, to save custom image in server onclick "login" button, we are using same function that "create" button is using as below code :

app/design/frontend/rwd/Theme3/template/productlike - index.phtml

<form action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect', 
array('_secure'=>(!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on'), 
'id' => Mage::registry('current_product')->getId())) ?>" id="ajaxlogin-login-form">

// code for email id and password //

<button onclick="initObservers()" type="submit" title="<?php echo $this->__('Login') ?>" 
name="send" id="send2"><span><?php echo $this->__('Login') ?></span>
</button>

</form>

but still custom image is not saving in server onclick "login" button.

Is this right way ?

updated code - >

                    $images = array(
                        'thumbnail' => 'image.png', // displaying under cart 
                        //'small_image' => 'image.png',
                        'image' => 'image.png' // displaying under my design
                    );

                    foreach ($images as $imageType => $imageFileName) {
                        if ($newImagePath != "") {
                            $dir  = Mage::getBaseDir('media') . DS . 'custom_product_preview/quote/';
                            $path = $dir . $newImagePath;
                        } else {
                            $dir  = Mage::getBaseDir('media') . DS . 'example/amasty/';
                            $path = $dir . $imageFileName;
                        }
2
  • Where is the image code?
    – urfusion
    Commented Apr 22, 2017 at 6:03
  • @urfusion updated the question with image code ....can you check and do something pls......
    – raj
    Commented Apr 22, 2017 at 9:02

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.