Jump to content

Loading Attributes using Jquery


khalilrumi

Recommended Posts

In order to make may Magento template faster, i am trying to use jquery to load configurable products options. How can i fetch these attributes by using jquery. I want to show default options initially and then customers can change options as per their needs.  

Link to comment
Share on other sites

Allright, the thing is that, with products like tables, chair and other decoration items, customers can select different colors before they buy. The first option is that i would have to create configurable options for each product and load them when the template loads. It can make loading slow.

 

Few options can be shown and then users can select other options if they like. thanks

Link to comment
Share on other sites

Resolved, i was using the following code,

 

<?php foreach($_attributes as $_attribute): ?>
<dt><label class="required"><em>*</em><?php echo $_attribute->getLabel() ?></label></dt>
<dd<?php if ($_attribute->decoratedIsLast){?> class="last"<?php }?>>
<div class="input-box">
<select name="super_attribute[<?php echo $_attribute->getAttributeId() ?>]" id="attribute<?php echo $_attribute->getAttributeId() ?>" class="required-entry super-attribute-select">
<option><?php echo $this->__('Choose an Option...') ?></option>
</select>
</div>
</dd>
<?php endforeach; ?>

 

 

Now i will fetch these options from spConfig.config.attributes, i will use following code:

 

<script type="text/javascript">

var spConfig = new Product.Config(<?php echo $this->getJsonConfig() ?>);
for(var i=spConfig.settings.length-1;i>=0;i--) {
spConfig.settings[i].selectedIndex = 1;
}
spConfig.reloadPrice();
</script>

 

 

Thanks,

Edited by khalilrumi
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.