function commerce_product_load_by_sku in Commerce Core 7
Loads a product by SKU.
Parameters
string $sku: The SKU to load.
bool $reset: Boolean to reset static cache.
7 calls to commerce_product_load_by_sku()
- CommerceProductCRUDTestCase::testCommerceProductCrud in modules/
product/ tests/ commerce_product.test - Test the product CRUD functions.
- CommerceProductUIAdminTest::testCommerceProductUIAddProduct in modules/
product/ tests/ commerce_product_ui.test - Test the add product process.
- CommerceProductUIAdminTest::testCommerceProductUIEditProduct in modules/
product/ tests/ commerce_product_ui.test - Test the edit process for a product.
- CommerceProductUIAdminTest::testCommerceProductUISaveAndAddAnother in modules/
product/ tests/ commerce_product_ui.test - Test the save and add another product.
- commerce_cart_rules_product_add_by_sku in modules/
cart/ commerce_cart.rules.inc - Rules action: adds a product to a user's shopping cart order.
1 string reference to 'commerce_product_load_by_sku'
- CommerceProductEntityController::save in modules/
product/ includes/ commerce_product.controller.inc - Saves a product.
File
- modules/
product/ commerce_product.module, line 519 - Defines the core Commerce product entity, including the entity itself, the bundle definitions (product types), and various API functions to manage products and interact with them through forms and autocompletes.
Code
function commerce_product_load_by_sku($sku, $reset = FALSE) {
$cache =& drupal_static(__FUNCTION__, array());
if (!isset($cache[$sku]) || $reset) {
$products = commerce_product_load_multiple(array(), array(
'sku' => $sku,
));
$cache[$sku] = $products ? reset($products) : FALSE;
}
return $cache[$sku];
}