6

We are calling same controller action for 2 buttons for create product pro-grammatically and assign a custom image for that product.

1. create - custom image uploading for newly created product

2. login - custom image not uploading for newly created product

Create:

<button  onclick="return setproductlogin(\'<?php echo Mage::registry("current_product")->getId()?>\', event);setrequestlogin();" id="submit-editorApply-{{rand}}" title="{{apply_text}}">{{apply_text}}</button>

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

Login code:

$params = array(
    '_secure' => (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on'),
    'id' => Mage::registry('current_product')->getId()
);

<form id="ajaxlogin-login-form" action="<?php echo $this->getUrl('example/amasty/createSimpleProductAndRedirect', $params) ?>">

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

Controller 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;
    }
}

Please give me some hint for this ...

  • Try to put log in controller for check in both button controller is called. – user52581 Apr 22 '17 at 11:30
  • @FeedlayTechnologies yes, in both buttons that controller is called because new product is creating programtically for both buttons, but only custom image is missing for login button...... – raj Apr 22 '17 at 11:36
  • @FeedlayTechnologies pleas help me for this, i am facing this issue from last 3 months and its completely destroying me mentally every day..... – raj Apr 22 '17 at 11:37
  • Can you give whole controller code, update in question – user52581 Apr 22 '17 at 11:44
  • in that please these 2 functions : createSimpleProductAndRedirectAction() and _createProduct – raj Apr 22 '17 at 11:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.