Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

mail_open
Showing Available Configurable Options for size
Jay Elliott

Excellent
July 31, 2014 - 9:58 pm
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

I found the perfect piece of php code from this site:
http://lastdropofink.co.uk/too…..n-magento/
Wink
I ran into a bit of a problem where I have different attributes for different configurable sizes, for instance: womens shorts 6,8,10,12. mens tee shirts s,m,l,xl
so I tried to edit the code:
isConfigurable()){
$allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
foreach ($allProducts as $subproduct) {
if ($subproduct->isSaleable() && floor($subproduct->getStockItem()->getQty()) > 0 ) {
$bikinisizes[] = $subproduct->getAttributeText(‘bikini_size’);
$wshortssizes[] = $subproduct->getAttributeText(‘w_shorts_size’);
}
}
if(count($bikinisizes)>0) {
sort($bikinisizes);
?>

Sizes:

0) {
sort($wshortssizes);
?>

sizes:

This works but now I get two sizes appear. One with the correct results and the other with size: ,,,, depending on which category I am viewing.
I think I need a If attribute name =”” then
Could someone lend a hand???

Avatar
Dave Furness

Founder
August 1, 2014 - 10:29 am
Member Since: July 19, 2013
Forum Posts: 4606
sp_UserOfflineSmall Offline

Hey Jay,

I keep hearing about this LastDropOfInk site, not sure who runs it though :)

This is a little codey for my knowledge so I have passed it on to Mr O and asked him to get back to you when he can :)

Dave

Every expert was once a beginner

Avatar
Matthew Ogborne

Founder
August 1, 2014 - 12:25 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Jay,

That code should work, I used it live on a clients site and it worked really well.

Then forums have chewed up the php code though, can you either use the code tags or paste the code in http://pastebin.com and paste the link here for me to take a look for you.

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Jay Elliott

Excellent
August 1, 2014 - 2:34 pm
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

Hi Matt,
The code works fine for one category that sells bikinis, I have added the configurable attribute name ‘bikini_size’ and all is good.
My problem is that in a category that sells mens tee shirts I need to assign the configurable attribute ‘mens_tees’
Then that’s where the problems start. I don’t know how to edit the code to deal with multiple configurable size attributes. I did try joining attribute names with a ; then a , but was grasping at straws really.
I have bikinis, shorts, tee shirts and flip flops all with different configurable size attributes.

Avatar
Matthew Ogborne

Founder
August 2, 2014 - 4:59 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Morning Jay,

Ah ha. Yea the site this was set up for just had those attributes only. The more you have the more code we need to add and the more times it needs to be checked, so anything more than 4 or so attributes would slow the page down as it runs for each product and each set of variations.

I’m using my phone at the moment, however I’ve copied this forums post URL and popped it in my calendar for Monday to check over it for you where I can look at this properly for you.

Can you confirm the attribute set and attribute names you wish to check for me please Jay?

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Jay Elliott

Excellent
August 3, 2014 - 10:46 pm
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

Hi Matt,
Hope you’ve had a good weekend.
The sets and names are below, worried about slowing the site down too much.
Would it work more efficiently if attributes were called dependent on what the URL is.
So if URL = bikinis, roxy-bikinis, o’neill-bikinis, billabong-bikinis or animal-bikinis then call attribute name bikini_size?
Or am I grasping at straws again. Embarassed

Attribute Set —- Attribute Name
Bikinis—- bikini_size
Mens_Flip_Flops—- m_flip_flops_size
Mens_Shorts —- m_shorts_size
Mens_Tshirts —- m_tshirt_size
Womens_Flip_Flops—- w_flip_flops_size
Womens_Shorts—- w_shorts_size

Thanks for looking.

Jay

Avatar
Matthew Ogborne

Founder
August 4, 2014 - 4:26 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Howdy Jay,

See below or on PasteBin here http://pastebin.com/0xGzmMB7

This has each of the attributes above. As there are quite a few see if this works ok and that it doesn’t impact the page load times too much.

The URL check is a good idea, although see how this works for you first.

<?php
$bikini_size = array();
$m_flip_flops_size = array();
$m_shorts_size = array();
$m_tshirt_size = array();
$w_flip_flops_size = array();
$w_shorts_size = array();
if($_product->isConfigurable()){
$allProducts = $_product->getTypeInstance(true)->getUsedProducts(null, $_product);
foreach ($allProducts as $subproduct) {
if ($subproduct->isSaleable() && floor($subproduct->getStockItem()->getQty()) > 0 ) {
$bikini_size[] = $subproduct->getAttributeText(‘bikini_size’);
$m_flip_flops_size[] = $subproduct->getAttributeText(‘m_flip_flops_size’);
$m_shorts_size[] = $subproduct->getAttributeText(‘m_shorts_size’);
$m_tshirt_size[] = $subproduct->getAttributeText(‘m_tshirt_size’);
$w_flip_flops_size[] = $subproduct->getAttributeText(‘w_flip_flops_size’);
$w_shorts_size[] = $subproduct->getAttributeText(‘w_shorts_size’);
}
}
if(count($bikini_size)>0) {
sort($bikini_size);
?>
<div class="desc std bikini_size">
Sizes: <? echo implode(", ", $bikini_size); ?>
</div>
<?
}
if(count($m_flip_flops_size)>0) {
sort($m_flip_flops_size);
?>
<div class="desc std m_flip_flops_size">
Sizes: <? echo implode(", ", $m_flip_flops_size); ?>
</div>
<?
}
if(count($m_shorts_size)>0) {
sort($m_shorts_size);
?>
<div class="desc std m_shorts_size">
Sizes: <? echo implode(", ", $m_shorts_size); ?>
</div>
<?
}
if(count($m_tshirt_size)>0) {
sort($m_tshirt_size);
?>
<div class="desc std m_tshirt_size">
Sizes: <? echo implode(", ", $m_tshirt_size); ?>
</div>
<?
}
if(count($w_flip_flops_size)>0) {
sort($w_flip_flops_size);
?>
<div class="desc std w_flip_flops_size">
Sizes: <? echo implode(", ", $w_flip_flops_size); ?>
</div>
<?
}
if(count($w_shorts_size)>0) {
sort($w_shorts_size);
?>
<div class="desc std w_shorts_size">
Sizes: <? echo implode(", ", $w_shorts_size); ?>
</div>
<?
}
}
?>

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Jay Elliott

Excellent
August 4, 2014 - 7:54 am
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

Morning Matt,

The code is pulling the correct data but displaying all snippets. Sorry my terminology is for code is bad. I’ll grab some screen shots:
These are screen shots from different sections.

BikinisImage Enlarger

ShortsImage Enlarger

Flip FlopsImage Enlarger

Avatar
Matthew Ogborne

Founder
August 4, 2014 - 8:20 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Jay,

Hmmm… it’s showing them all, so the conditional check isn’t working right.

Let me tweak that code for you.

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Avatar
Matthew Ogborne

Founder
August 4, 2014 - 8:26 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Jay,

Try this version: http://pastebin.com/S2jwKnu9 and let me know how they come out.

Failing that we’ll have to check each attributes existence and then add to the array (basically I have a plan B as well).

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Jay Elliott

Excellent
August 4, 2014 - 11:21 am
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

Ok Smarty Pants!!
It works perfectly!!
I’ve got the kids today but this evening I will check the speed of the site pages with and without the code just to see how it effects performance.
Have a good day Matt.

Avatar
Matthew Ogborne

Founder
August 4, 2014 - 3:06 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Howdy Jay,

Happy Days, I’m glad that’s worked for you.

Let em know how you get on as I’m curious :)

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Jay Elliott

Excellent
August 5, 2014 - 2:19 pm
Member Since: February 28, 2014
Forum Posts: 19
sp_UserOfflineSmall Offline

Hi Matt,
Sorry for delay. Product grid pages are loading just under 2 seconds so I’m really pleased with that. index (home) page is running just over 4 seconds so will look at ways of getting that down a bit.

Cant thank you enough mate. Now I just need to start generating some sales, going to hit the Amazon and Ebay tutorials tonight.

Thanks again

Jay

Avatar
Matthew Ogborne

Founder
August 5, 2014 - 4:58 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Howdy Jay,

Oh that’s fab to hear, I was a little concerned that this may increase the page load times, obviously nothing noticable then :)

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

 

Why Should You Join UnderstandingE?

 
  • Access to over 500 step-by-step video tutorials
  • +20 video courses available
  • Magento, M2E Pro, Magmi, eBay, Amazon & Design all covered
  • Everything is in 100% Plain English
  • Learn how to build your own multi-channel software for eBay & Amazon
  • Access to the community forums, meet fellow business owners like yourself

Join Now with 2 Clicks

 

Join now for less that £1 per day you can gain access to over 400 step-by-step video tutorials & learn how to build your very own multi-channel software.

 

Forum Timezone: Europe/London

Most Users Ever Online: 1012

Currently Online:
33 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Jim @ Moogento: 688

Steve Froggatt: 514

Badeth - UE: 513

Jimbob: 453

Paul Cartwright: 414

Forum Stats:

Groups: 6

Forums: 37

Topics: 5221

Posts: 27485

Administrators: Matthew Ogborne: 4565, Dave Furness: 4606