JM ColorSwatch sorting

Hi,

as you can see in the attached file, the order/position of the attribute values in the backend/default magento dropdown doesn’t match the position of the Colorwatch πŸ™

I tried changing the position in the attribute values position (backend) , it works OK with default magento dropdown but when I activate the Colorswatch, the position is wrong again…

If backend shows like this: S M L XL XXL
Colorwatch shows: M XL S XXL L

Where can I control the order/sorting of attribute values in Colorswatch?

http://runwild.no/utv/index.php/2xu-…ket-herre.html

Another question:
Is this module meant to be used only with "size" attribute? I create new attribute called "size2" and it shows only as Dropdown …. the module doesn’t work at all with that!

Thanks

15 answers

Profile photo of Birger Kvam 0.00 $tone October 30, 2014
Public

After the fix you uploaded, the order/position works OK but there is another bug, SIZE that is not available in stock used to show as inactive, light gray color with class="disabled".
Now it doesn’t show at all !!!
I guess there is something wrong here:

Code:

                      
else{
newspan.addClass("disabled"); 
}
newspan.html($jm(op).text());
if($jm(op).val() != ''){
newspan.appendTo(newselect);
}

Thanks

ps. the first post is already solved but that data loss has deleted the solution!

#1
Profile photo of Mall Staff 184060.00 $tone October 31, 2014
Public

Yes, that is right. If you want to show all, let download the file jmcolorswatch.zip again and then extract & upload replace this file: /skin/frontend/default/jm_sporty/joomlart/jmcolorswatch/js/jmcolorswatch.js

And let me know if you need further help.

#2
Profile photo of Birger Kvam 0.00 $tone October 31, 2014
Public

Thanks,

I downloaded the file (btw. you have uploaded 2 files) , tried them both and still it doesn’t work πŸ™

The original file that works very good, except the wrong ordering/position of values is here. If you manage to just fix the ordering without changing other things, would be really great

Thanks again!

#3
Profile photo of Mall Staff 184060.00 $tone November 3, 2014
Public

I have updated the attached file jmcolorswatch.zip in previous reply.
As i said, to show all sizes as you want. please download the file jmcolorswatch.zip again and then extract & upload & replace this file: /skin/frontend/default/jm_sporty/joomlart/jmcolorswatch/js/jmcolorswatch.js
Don’t forget clean the Magento cache after changing.

And inform me the results once done.

#4
Profile photo of Birger Kvam 0.00 $tone November 3, 2014
Public

Sorry to say but it still doesn’t work, only the stock available products show πŸ™

No spans with class "disabled" are generated ….

Btw, why did you deactivate:

Code:

//                     
else{
//                       newspan.addClass("disabled");
//                     }
#5
Profile photo of Mall Staff 184060.00 $tone November 4, 2014
Public

CODE]
//
else{
// newspan.addClass("disabled");
// }
[/CODE]

We comment it in order to show all sizes as you want:

SIZE that is not available in stock used to show as inactive, light gray color with class="disabled".
Now it doesn’t show at all !!!

Also, to show both out of stock products, you need to enable it from config in back-end
Please enable this option at menu navigation at System/Configuration/Catalog/Inventory/Display Out of Stock Products

#6
Profile photo of Birger Kvam 0.00 $tone November 4, 2014
Public

OK, I see we are getting a little bit lost … to make it easy:

This was the original script and you can see it shows the sizes that are not available in stock (size S) as inactive, light gray color with class="disabled".
http://runwild.no/utv/index.php/2xu-…ion-short.html
This works even if you don’t activate to show both out of stock products in back-end!

This is the last script that you have uploaded here:
http://runwild.no/dame/treningsklaer…re-genser.html
The product has a size L and you can see it does not show at all even if I activate to show both out of stock products in back-end!!!

Can you please fix the script so it works like the original did?

Thanks

#7
Profile photo of Mall Staff 184060.00 $tone November 5, 2014
Public

For your concern of size attribute, I have to add more PHP function code in JmColorwatch extension. And I also udated the code of jmcolorswatch.js & a template view in jm_sporty theme at /app/design/frontend/default/jm_sporty/template/catalog/product/view.phtml

So try to download the below attached file jmcolorswatch.zip in this reply & then extract & upload to your server of your website.

Note:
-- Upload the file Data.php to folder named: /app/code/local/JoomlArt/JmColorSwatch/Helper/
-- Upload the file view.phtml to folder named: /app/design/frontend/default/jm_sporty/template/catalog/product/
-- Upload the file jmcolorswatch.js to folder named: /skin/frontend/default/jm_sporty/joomlart/jmcolorswatch/js/
-- Clean the Magento cache after changing.

And let me know how it goes.

#8
Profile photo of Birger Kvam 0.00 $tone November 5, 2014
Public

Well, it works but now you have limited it to only one attribute (attributeid:983) again. That’s funny because I asked you before for help to making it work with many attributes and you did that, now you reversed it back again πŸ™

Here is the code you send to me before: (view.phtml and not view.php )

Code:

<?php $_helper = $this->helper('catalog/output'); ?>
<?php $_product = $this->getProduct(); 
    $baseconfig =  Mage::helper("jmbasetheme")->getactiveprofile();
?>
<?php if($_product->isConfigurable() && Mage::helper("jmcolorswatch")->get('show')) { 
         $associtates = Mage::helper("jmcolorswatch")->getassociatedproducts($_product->getId());
         $attrcode1 = Mage::getModel('eav/entity_attribute')->load(983)->getAttributeCode();
         $attrcode2 = Mage::getModel('eav/entity_attribute')->load(986)->getAttributeCode();
         $attrcode3 = Mage::getModel('eav/entity_attribute')->load(987)->getAttributeCode();
         $attrcode4 = Mage::getModel('eav/entity_attribute')->load(993)->getAttributeCode();
         $products_arr_qty1 = array();  
         $products_arr_qty2 = array();  
         $products_arr_qty3 = array(); 
         $products_arr_qty4 = array(); 
         if(is_array($associtates)){
            foreach($associtates as $productid){
            	  $product = Mage::getModel('catalog/product')->load($productid);
            	  $stocklevel = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productid);
                  $products_arr_qty1[$product->getData($attrcode1)] = $stocklevel->getQty();
                  $attribute_arr1[$product->getData($attrcode1)] = $product->getAttributeText($attrcode1);
				  
				  $products_arr_qty2[$product->getData($attrcode2)] = $stocklevel->getQty();
                  $attribute_arr2[$product->getData($attrcode2)] = $product->getAttributeText($attrcode2);
				  
				  $products_arr_qty3[$product->getData($attrcode3)] = $stocklevel->getQty();
                  $attribute_arr3[$product->getData($attrcode3)] = $product->getAttributeText($attrcode3);
				  
				  $products_arr_qty4[$product->getData($attrcode4)] = $stocklevel->getQty();
                  $attribute_arr4[$product->getData($attrcode4)] = $product->getAttributeText($attrcode4);
            }

         }
         //asort($attribute_arr);
?>

<?php
	$check_arr1 = array();
	$check_arr1 = array_count_values($attribute_arr1);
	
	$check_arr2 = array();
	$check_arr2 = array_count_values($attribute_arr2);
	
	$check_arr3 = array();
	$check_arr3 = array_count_values($attribute_arr3);
	
	$check_arr4 = array();
	$check_arr4 = array_count_values($attribute_arr4);
?>
 
	<script type="text/javascript">
	<?php if (!empty($check_arr1)):?>
		 if(<?php echo json_encode($attribute_arr1); ?> != null){
	   jQuery(document).ready(function() {
	        	jQuery("div.product-options").jmproductdetail({
	        		      attribute:"<?php echo $attrcode1; ?>",
	        		      attributeid:983,
	        		      mainproduct:<?php echo $_product->getId(); ?>,
	        		      attribute_qtys:<?php echo json_encode($products_arr_qty1); ?>,
	        		      attribute_arr:<?php echo json_encode($attribute_arr1); ?>
	        		  });
	        });
	   }
	  <?php endif;?>
	   
	   <?php if (!empty($check_arr2)):?>
	    if(<?php echo json_encode($attribute_arr2); ?> != null){
	   jQuery(document).ready(function() {
	        	jQuery("div.product-options").jmproductdetail({
	        		      attribute:"<?php echo $attrcode2; ?>",
	        		      attributeid:986,
	        		      mainproduct:<?php echo $_product->getId(); ?>,
	        		      attribute_qtys:<?php echo json_encode($products_arr_qty2); ?>,
	        		      attribute_arr:<?php echo json_encode($attribute_arr2); ?>
	        		  });
				});
	   }
	   <?php endif;?>
	   
	   <?php if (!empty($check_arr3)):?>
	    if(<?php echo json_encode($attribute_arr3); ?> != null){
	   jQuery(document).ready(function() {
	        	jQuery("div.product-options").jmproductdetail({
	        		      attribute:"<?php echo $attrcode3; ?>",
	        		      attributeid:987,
	        		      mainproduct:<?php echo $_product->getId(); ?>,
	        		      attribute_qtys:<?php echo json_encode($products_arr_qty3); ?>,
	        		      attribute_arr:<?php echo json_encode($attribute_arr3); ?>
	        		  });
				});
	   }
	   <?php endif;?>
	   
	   <?php if (!empty($check_arr4)):?>
	    if(<?php echo json_encode($attribute_arr4); ?> != null){
	   jQuery(document).ready(function() {
	        	jQuery("div.product-options").jmproductdetail({
	        		      attribute:"<?php echo $attrcode4; ?>",
	        		      attributeid:993,
	        		      mainproduct:<?php echo $_product->getId(); ?>,
	        		      attribute_qtys:<?php echo json_encode($products_arr_qty4); ?>,
	        		      attribute_arr:<?php echo json_encode($attribute_arr4); ?>
	        		  });
				});
	   }
	   <?php endif;?>
	   
	   
	 </script>  
<?php } ?>

As you can see I need it to work with:

attributeid:983
attributeid:986
attributeid:987
attributeid:993

Thanks

#9
Profile photo of Mall Staff 184060.00 $tone November 5, 2014
Public

Did you customize our jm_sporty theme?
If so, please PM me the FTP credentials of your website.
I will help you fix directly in your custom view in Jm_sporty theme.

#10
Profile photo of Mall Staff 184060.00 $tone November 6, 2014
Public

I have created a backup the template file at: /app/design/frontend/default/jm_sporty/template/catalog/product/view.phtml
and updated the java script file at: /skin/frontend/default/jm_sporty/joomlart/jmcolorswatch/js/jmcolorswatch.js

The Jm colorswatch extension is able to work with multiple attributes as you want: attribute_ids: 983, 986, 987, 993
You can see more details at this file: /app/design/frontend/default/jm_sporty/template/catalog/product/view.phtml

Note: I have only fixed in website at: http://runwild.no/utv/index.php/

Kindly take a look.

#12
Profile photo of Birger Kvam 0.00 $tone November 6, 2014
Public

Thanks,

I copied the files (view.phtml and jmcolorswatch.js) from utv to the live site www and I got BLANK page in the product view πŸ™

Can you test it on the live site, please?

#13
Profile photo of Mall Staff 184060.00 $tone November 6, 2014
Public

QUOTE]
I copied the files (view.phtml and jmcolorswatch.js) from utv to the live site www and I got BLANK page in the product view :

That is because you customized our template view at: /app/design/frontend/default/jm_sporty/template/catalog/product/view.phtml
and this file was missing: /app/code/local/JoomlArt/JmColorSwatch/Helper/Data.php

I have created a backup & updated 3 files in your live website at http://runwild.no
File 1: /app/code/local/JoomlArt/JmColorSwatch/Helper/Data.php
File 2: /app/design/frontend/default/jm_sporty/template/catalog/product/view.phtml
File 3: /skin/frontend/default/jm_sporty/joomlart/jmcolorswatch/js/jmcolorswatch.js

In your live website, the Jm colorswatch extension is able to work with multiple attributes as you want: attribute_ids: 983, 986, 987, 993

Please be carefull when customize if you’re not sure as it will be really hard to detect the root of issue.

#14

This question is now closed

Written By

Comments