$('#artsearch').keyup(function(){
var searchtext = $('#artsearch').val();
if(searchtext.length >= 3){
$('#photoPreview .file-row').each(function(){
var $this = $(this);
var $text = $this.find('.arttitle .name').text();
var indexcount = $text.indexOf(searchtext);
if(indexcount > -1){
$this.show();
}else{
$this.hide();
}
});
}
if(searchtext.length == 0){
$('#photoPreview .file-row').show();
}
});
Shopify, Shopify Apps, Magento, WordPress, Codeigniter, Joomla, Big Commerce | PHP
Thursday, 10 November 2016
Search with jQuery / Javascript
Saturday, 8 October 2016
How to upload products multiple images in codeigniter Gocart in admin panel
Open : gocart/views/admin/iframe/product_image_uploader.php
Update product_image_upload() function
Open : gocart/views/admin/product_form.php
Update : add_product_image(data) function
<?php include('header.php');?>Open : gocart/controllers/admin/products.php
<script type="text/javascript">
<?php if( $this->input->post('submit') ):?>
$(window).ready(function(){
$('#iframe_uploader', window.parent.document).height($('body').height()); });
<?php endif;?>
<?php if($file_name):?>
parent.add_product_image('<?php echo json_encode($file_name);?>');
<?php endif;?>
</script>
<?php if (!empty($error)): ?>
<div class="alert alert-error">
<a class="close" data-dismiss="alert">×</a>
<?php echo $error; ?>
</div>
<?php endif; ?>
<div class="row-fluid">
<div class="col-md-12">
<?php echo form_open_multipart($this->config->item('admin_folder') . '/products/product_image_upload', 'class="form-inline "'); ?>
<?php echo form_upload(array('name' => 'userfile[]', 'id' => 'userfile', 'class' => 'input-file', 'multiple'=>"true" )); ?>
<input class="btn" name="submit" type="submit" value="<?php echo lang('upload'); ?>" />
</form>
</div>
</div>
<?php include('footer.php');
Update product_image_upload() function
function product_image_upload() {
$data['file_name'] = false;
$data['error'] = false;
$config['allowed_types'] = 'gif|jpg|png';
//$config['max_size'] = $this->config->item('size_limit');
$config['upload_path'] = 'uploads/images/full';
$config['encrypt_name'] = true;
$config['remove_spaces'] = true;
$this->load->library('upload', $config);
$files = $_FILES;
$cpt = count($_FILES['userfile']['name']);
for($i=0; $i<$cpt; $i++)
{
$_FILES['userfile']['name']= $files['userfile']['name'][$i];
$_FILES['userfile']['type']= $files['userfile']['type'][$i];
$_FILES['userfile']['tmp_name']= $files['userfile']['tmp_name'][$i];
$_FILES['userfile']['error']= $files['userfile']['error'][$i];
$_FILES['userfile']['size']= $files['userfile']['size'][$i];
//$this->upload->initialize($this->set_upload_options());
if ($this->upload->do_upload()) {
$upload_data = $this->upload->data();
$this->load->library('image_lib');
/*
I find that ImageMagick is more efficient that GD2 but not everyone has it
if your server has ImageMagick then you can change out the line
$config['image_library'] = 'gd2';
with
$config['library_path'] = '/usr/bin/convert'; //make sure you use the correct path to ImageMagic
$config['image_library'] = 'ImageMagick';
*/
//this is the larger image
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/images/full/' . $upload_data['file_name'];
$config['new_image'] = 'uploads/images/medium/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 600;
$config['height'] = 500;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
//small image
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/images/medium/' . $upload_data['file_name'];
$config['new_image'] = 'uploads/images/small/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 235;
$config['height'] = 235;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
//cropped thumbnail
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/images/small/' . $upload_data['file_name'];
$config['new_image'] = 'uploads/images/thumbnails/' . $upload_data['file_name'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 150;
$config['height'] = 150;
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
$data['file_name'][] = $upload_data['file_name'];
}
}
if ($this->upload->display_errors() != '') {
$data['error'] = $this->upload->display_errors();
}
$this->load->view($this->config->item('admin_folder') . '/iframe/product_image_uploader', $data);
}
Open : gocart/views/admin/product_form.php
Update : add_product_image(data) function
function add_product_image(data) {
var $images = $.parseJSON(data);
$.each($images, function(i, image) {
p = image.split('.');
var photo = '<?php add_image("' + p[0] + '", "' + p[0] + '.' + p[1] + '", '
', '
', '
', base_url('
uploads / images / thumbnails '));?>';
$('#gc_photos').append(photo);
$('#gc_photos').sortable('destroy');
photos_sortable();
});
}
Thursday, 22 September 2016
Adding an existing project to GitHub /Bitbucket using the command line
1. Create a new repository on GitHub. To avoid errors, do not initialize the new repository with README, license, or gitignore files. You can add these files after your project has been pushed to GitHub.
2. Open Terminal.
3. Change the current working directory to your local project.
4. Initialize the local directory as a Git repository.
5. Add the files in your new local repository. This stages them for the first commit.
6. Commit the files that you've staged in your local repository.
7. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
8. In Terminal, add the URL for the remote repository where your local repository will be pushed.
9. Push the changes in your local repository to GitHub.
2. Open Terminal.
3. Change the current working directory to your local project.
4. Initialize the local directory as a Git repository.
$ git init
5. Add the files in your new local repository. This stages them for the first commit.
$ git add .
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.
6. Commit the files that you've staged in your local repository.
$ git commit -m "First commit"
# Commits the tracked changes and prepares them to be pushed to a remote repository. To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.
7. At the top of your GitHub repository's Quick Setup page, click to copy the remote repository URL.
8. In Terminal, add the URL for the remote repository where your local repository will be pushed.
$ git remote add origin remote repository URL
# Sets the new remote
$ git remote -v
# Verifies the new remote URL
9. Push the changes in your local repository to GitHub.
$ git push origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin
Wednesday, 21 September 2016
How to get value from controller to phtml / view / template file in magento
You can use magento registry for set and get values
Set a value (in controller)
Get a value (in phtml/view/template)
Set a value (in controller)
Mage::register('variable_name', $variable_value);
Get a value (in phtml/view/template)
$var_value = Mage::registry('variable_name');
How to get a url parameter in Magento controller?
Is there a Magento function to get the value of "id" from this url:
http://domain.com/path/action/id/123
http://domain.com/path/action/id/123
$id = $this->getRequest()->getParam('id', 0);
Friday, 16 September 2016
How to get POST and GET data variables after submit a form in Magento
There Are two steps for get post/get data in magento
1 Way : You can get all variables using $this->getRequest()->getParams();
2 Way : You can get one variable using $this->getRequest()->getParam('id');
1 Way : You can get all variables using $this->getRequest()->getParams();
2 Way : You can get one variable using $this->getRequest()->getParam('id');
Thursday, 15 September 2016
How to change the sort order for shipping in admin panel in magento
Step 1 : You have to copy this two files to your Theme in the adminhtml
app/design/adminhtml/default/default/template/sales/order/shipment/create/tracking.phtml
app/design/adminhtml/default/default/template/sales/order/invoice/create/tracking.phtml
Step 2 : Open : app/design/adminhtml/default/default/template/sales/order/shipment/create/tracking.phtml
(you will find this code at Line number 93)
Replace with
<select name="tracking[__index__][carrier_code]" id="trackingC__index__" class="select carrier" style="width:110px;" disabled="disabled">
<?php foreach ($this->getCarriers() as $_code=>$_name): ?>
<option value="<?php echo $_code ?>"><?php echo $this->escapeHtml($_name) ?></option>
<?php endforeach; ?>
</select>
Step 3 : Open : app/design/adminhtml/default/default/template/sales/order/invoice/create/tracking.phtml
(you will find this code at Line number 93)
Replace with
<select name="tracking[__index__][carrier_code]" id="trackingC__index__" class="select carrier" style="width:110px;" disabled="disabled">
<?php foreach ($this->getCarriers() as $_code=>$_name): ?>
<option <?php if ($_code=="ups"): ?>selected<?php endif; ?> value="<?php echo $_code ?>"><?php echo $this->escapeHtml($_name) ?></option>
<?php endforeach; ?>
</select>
Subscribe to:
Posts (Atom)