Skip to main content
Applying what I think the original author intended
Source Link

I'm not 100% sure what do you want to achieve, but either way this is not how to determine if the product belongs to any configurable product. You see simple product can be a child of a configurable product, it can be independent product and it can be both and there should be regarded as such.

I think the best way to determine if the simple product is pure child product is to check its visibility, i.e. check whether or not it's "Not Visible Individually". Easiest way to check visibility is:

$_product->getVisibility();

Return values are:

const VISIBILITY_NOT_VISIBLE    = 1;
const VISIBILITY_IN_CATALOG     = 2;
const VISIBILITY_IN_SEARCH      = 3;
const VISIBILITY_BOTH           = 4;

So if you want to see if the product is not visible individually check:

if ($_product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NO_INDIVIDUALLYVISIBILITY_NOT_VISIBLE) 
  echo 'Product not visible individually';

I'm not 100% sure what do you want to achieve, but either way this is not how to determine if the product belongs to any configurable product. You see simple product can be a child of a configurable product, it can be independent product and it can be both and there should be regarded as such.

I think the best way to determine if the simple product is pure child product is to check its visibility, i.e. check whether or not it's "Not Visible Individually". Easiest way to check visibility is:

$_product->getVisibility();

Return values are:

const VISIBILITY_NOT_VISIBLE    = 1;
const VISIBILITY_IN_CATALOG     = 2;
const VISIBILITY_IN_SEARCH      = 3;
const VISIBILITY_BOTH           = 4;

So if you want to see if the product is not visible individually check:

if ($_product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NO_INDIVIDUALLY) 
  echo 'Product not visible individually';

I'm not 100% sure what do you want to achieve, but either way this is not how to determine if the product belongs to any configurable product. You see simple product can be a child of a configurable product, it can be independent product and it can be both and there should be regarded as such.

I think the best way to determine if the simple product is pure child product is to check its visibility, i.e. check whether or not it's "Not Visible Individually". Easiest way to check visibility is:

$_product->getVisibility();

Return values are:

const VISIBILITY_NOT_VISIBLE    = 1;
const VISIBILITY_IN_CATALOG     = 2;
const VISIBILITY_IN_SEARCH      = 3;
const VISIBILITY_BOTH           = 4;

So if you want to see if the product is not visible individually check:

if ($_product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) 
  echo 'Product not visible individually';
Source Link
Pronto
  • 3.4k
  • 1
  • 16
  • 33

I'm not 100% sure what do you want to achieve, but either way this is not how to determine if the product belongs to any configurable product. You see simple product can be a child of a configurable product, it can be independent product and it can be both and there should be regarded as such.

I think the best way to determine if the simple product is pure child product is to check its visibility, i.e. check whether or not it's "Not Visible Individually". Easiest way to check visibility is:

$_product->getVisibility();

Return values are:

const VISIBILITY_NOT_VISIBLE    = 1;
const VISIBILITY_IN_CATALOG     = 2;
const VISIBILITY_IN_SEARCH      = 3;
const VISIBILITY_BOTH           = 4;

So if you want to see if the product is not visible individually check:

if ($_product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NO_INDIVIDUALLY) 
  echo 'Product not visible individually';