Version Notes
Changes to getting attributes for configurable products.
Download this release
Release Info
| Developer | Xpressbuy Inc. |
| Extension | xpressbuy_product_variants |
| Version | 0.0.3 |
| Comparing to | |
| See all releases | |
Code changes from version 0.0.2 to 0.0.3
- app/code/local/XpressBuy/ProductVariants/changelog.txt +0 -2
- app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/Model/Api.php +25 -10
- app/code/local/Xpressbuy/ProductVariants/changelog.txt +7 -0
- app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/etc/api.xml +0 -0
- app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/etc/config.xml +0 -0
- package.xml +13 -43
app/code/local/XpressBuy/ProductVariants/changelog.txt
DELETED
|
@@ -1,2 +0,0 @@
|
|
| 1 |
-
=== 0.0.1 (09-28-2015 ) ===
|
| 2 |
-
* First version
|
|
|
|
|
|
app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/Model/Api.php
RENAMED
|
@@ -24,18 +24,24 @@ class XpressBuy_ProductVariants_Model_Api extends Mage_Catalog_Model_Api_Resourc
|
|
| 24 |
return null;
|
| 25 |
}
|
| 26 |
$res["variants"] = array();
|
|
|
|
| 27 |
// Collect options applicable to the configurable product
|
| 28 |
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
|
|
|
| 29 |
$attributeOptions = array();
|
| 30 |
-
$
|
| 31 |
foreach ($productAttributeOptions as $productAttribute) {
|
| 32 |
foreach ($productAttribute['values'] as $attribute) {
|
| 33 |
-
$attributeOptions[$productAttribute['
|
| 34 |
$attr = new stdClass();
|
|
|
|
| 35 |
$attr->code = $attribute['value_index'];
|
| 36 |
-
$attr->value = $attribute['store_label'];
|
| 37 |
-
$attr->
|
| 38 |
-
$
|
|
|
|
|
|
|
|
|
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
|
@@ -45,7 +51,7 @@ class XpressBuy_ProductVariants_Model_Api extends Mage_Catalog_Model_Api_Resourc
|
|
| 45 |
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
| 46 |
foreach ($simple_collection as $simple_product) {
|
| 47 |
$prod_options = [];
|
| 48 |
-
$variant_prod = $this->getVariantProduct($simple_product, $attr_types, $
|
| 49 |
array_push($res['variants'], $variant_prod);
|
| 50 |
}
|
| 51 |
}
|
|
@@ -62,15 +68,17 @@ class XpressBuy_ProductVariants_Model_Api extends Mage_Catalog_Model_Api_Resourc
|
|
| 62 |
* @param $simple_product
|
| 63 |
* @param $attr_types
|
| 64 |
* @param $extraOptions
|
| 65 |
-
* @param $
|
| 66 |
* @return array
|
| 67 |
*/
|
| 68 |
-
public function getVariantProduct($simple_product, $attr_types, $extraOptions, $
|
| 69 |
{
|
| 70 |
$product_id = $simple_product->getId();
|
|
|
|
| 71 |
foreach ($attr_types as $attr_type) {
|
| 72 |
$attr_code = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product_id, $attr_type);
|
| 73 |
-
$
|
|
|
|
| 74 |
}
|
| 75 |
$final_price = $simple_product->getFinalPrice();
|
| 76 |
$regular_price = $simple_product->getPrice();
|
|
@@ -86,6 +94,11 @@ class XpressBuy_ProductVariants_Model_Api extends Mage_Catalog_Model_Api_Resourc
|
|
| 86 |
$base_image['url'] = (string)Mage::Helper('catalog/image')->init($simple_product, 'image', $base_image['file']);
|
| 87 |
$images_with_base_url[] = $base_image;
|
| 88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
$variant_prod = array(
|
| 90 |
'product_id' => $product_id,
|
| 91 |
'sku' => $simple_product->getSku(),
|
|
@@ -93,7 +106,9 @@ class XpressBuy_ProductVariants_Model_Api extends Mage_Catalog_Model_Api_Resourc
|
|
| 93 |
'price' => $regular_price,
|
| 94 |
'special_price' => ($special_price),
|
| 95 |
'images' => $images_with_base_url,
|
| 96 |
-
'
|
|
|
|
|
|
|
| 97 |
);
|
| 98 |
return $variant_prod;
|
| 99 |
}
|
| 24 |
return null;
|
| 25 |
}
|
| 26 |
$res["variants"] = array();
|
| 27 |
+
|
| 28 |
// Collect options applicable to the configurable product
|
| 29 |
$productAttributeOptions = $product->getTypeInstance(true)->getConfigurableAttributesAsArray($product);
|
| 30 |
+
|
| 31 |
$attributeOptions = array();
|
| 32 |
+
$extraOptions = array();
|
| 33 |
foreach ($productAttributeOptions as $productAttribute) {
|
| 34 |
foreach ($productAttribute['values'] as $attribute) {
|
| 35 |
+
$attributeOptions[$productAttribute['attribute_code']] = $productAttribute['attribute_code'];
|
| 36 |
$attr = new stdClass();
|
| 37 |
+
// $attr->attribute_id = $productAttribute["attribute_id"];
|
| 38 |
$attr->code = $attribute['value_index'];
|
| 39 |
+
// $attr->value = $attribute['store_label'];
|
| 40 |
+
// $attr->super_attribute_id = $attribute['product_super_attribute_id'];
|
| 41 |
+
// $attr->type = $productAttribute['attribute_code'];
|
| 42 |
+
// $attr->label = $productAttribute['label'];
|
| 43 |
+
// $otherOptions[$attr->code] = $attr;
|
| 44 |
+
$extraOptions[$attr->code] = $productAttribute;
|
| 45 |
}
|
| 46 |
}
|
| 47 |
|
| 51 |
$simple_collection = $conf->getUsedProductCollection()->addAttributeToSelect('*')->addFilterByRequiredOptions();
|
| 52 |
foreach ($simple_collection as $simple_product) {
|
| 53 |
$prod_options = [];
|
| 54 |
+
$variant_prod = $this->getVariantProduct($simple_product, $attr_types, $extraOptions, $prod_options);
|
| 55 |
array_push($res['variants'], $variant_prod);
|
| 56 |
}
|
| 57 |
}
|
| 68 |
* @param $simple_product
|
| 69 |
* @param $attr_types
|
| 70 |
* @param $extraOptions
|
| 71 |
+
* @param $productOptions
|
| 72 |
* @return array
|
| 73 |
*/
|
| 74 |
+
public function getVariantProduct($simple_product, $attr_types, $extraOptions, $productOptions)
|
| 75 |
{
|
| 76 |
$product_id = $simple_product->getId();
|
| 77 |
+
$attribute_info = [];
|
| 78 |
foreach ($attr_types as $attr_type) {
|
| 79 |
$attr_code = Mage::getResourceModel('catalog/product')->getAttributeRawValue($product_id, $attr_type);
|
| 80 |
+
$attribute_info[] = $extraOptions[$attr_code];
|
| 81 |
+
$productOptions[$attr_type] = $simple_product->getAttributeText($attr_type);
|
| 82 |
}
|
| 83 |
$final_price = $simple_product->getFinalPrice();
|
| 84 |
$regular_price = $simple_product->getPrice();
|
| 94 |
$base_image['url'] = (string)Mage::Helper('catalog/image')->init($simple_product, 'image', $base_image['file']);
|
| 95 |
$images_with_base_url[] = $base_image;
|
| 96 |
}
|
| 97 |
+
|
| 98 |
+
// $variant_type = $simple_product->getAttributeText('color');
|
| 99 |
+
// if($variant_type == null) {
|
| 100 |
+
$variant_type = $simple_product->getName();
|
| 101 |
+
// }
|
| 102 |
$variant_prod = array(
|
| 103 |
'product_id' => $product_id,
|
| 104 |
'sku' => $simple_product->getSku(),
|
| 106 |
'price' => $regular_price,
|
| 107 |
'special_price' => ($special_price),
|
| 108 |
'images' => $images_with_base_url,
|
| 109 |
+
'type' => $variant_type,
|
| 110 |
+
'productOptions' => $productOptions,
|
| 111 |
+
'attribute_info' => $attribute_info,
|
| 112 |
);
|
| 113 |
return $variant_prod;
|
| 114 |
}
|
app/code/local/Xpressbuy/ProductVariants/changelog.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
=== 0.0.1 (09-28-2015 ) ===
|
| 2 |
+
* First version
|
| 3 |
+
=== 0.0.2 (10-05-2015 ) ===
|
| 4 |
+
* chnages to description
|
| 5 |
+
=== 0.0.3 (05-23-2016 ) ===
|
| 6 |
+
* configurable product attribute retrieval
|
| 7 |
+
|
app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/etc/api.xml
RENAMED
|
File without changes
|
app/code/local/{XpressBuy → Xpressbuy}/ProductVariants/etc/config.xml
RENAMED
|
File without changes
|
package.xml
CHANGED
|
@@ -1,53 +1,23 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>xpressbuy_product_variants</name>
|
| 4 |
-
<version>0.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
-
<summary>
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
Xpressbuy leverages the Magento’s Product API to retrieve product variants and related products. This information is displayed to the user to as part of XpressBuy checkout.
|
| 22 |
-

|
| 23 |
-
Basket Creation in Magento
|
| 24 |
-
XpressBuy uses this extension to create orders that include shipping, billing, quantity and selected product variants (product id).
|
| 25 |
-

|
| 26 |
-
How it works
|
| 27 |
-

|
| 28 |
-
Xpressbuy retrieves product variants and related products
|
| 29 |
-
Customer adds these products to cart
|
| 30 |
-
Upon customer checkout Xpressbuy creates order with selected products and variants.
|
| 31 |
-
Merchant Benefits
|
| 32 |
-

|
| 33 |
-
Related products:
|
| 34 |
-
Showing related products to customer will reduce the customer burden to search for them.
|
| 35 |
-

|
| 36 |
-
Increased sales:
|
| 37 |
-
Relevant products at correct time means more sales total.
|
| 38 |
-

|
| 39 |
-
Customer Benefits:
|
| 40 |
-

|
| 41 |
-
Choice:
|
| 42 |
-
User will have choice to choose which product to buy(which color or size)
|
| 43 |
-

|
| 44 |
-
Smooth Add to Cart step: Customer's don't need to leave product information page in order to find related product. It makes it easy for customer to select product options (color, size etc.) during 'Add to Cart'.</description>
|
| 45 |
-
<notes>* Description modifications
|
| 46 |
-
* Changed Release Stability to Stable.</notes>
|
| 47 |
-
<authors><author><name>XpressBuy Inc.</name><user>xpressbuy</user><email>mag@getxpressbuy.com</email></author></authors>
|
| 48 |
-
<date>2015-10-05</date>
|
| 49 |
-
<time>19:19:28</time>
|
| 50 |
-
<contents><target name="magelocal"><dir name="XpressBuy"><dir name="ProductVariants"><dir name="Model"><file name="Api.php" hash="60fde9598b2cc14c857b0c3d94f7befd"/></dir><file name="changelog.txt" hash="2c9061dd93babf4499d46916588baef8"/><dir name="etc"><file name="api.xml" hash="74ff86f7267809f463c02193a5de32f2"/><file name="config.xml" hash="7085bf73362265779d4880b693859b1a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="XpressBuy_ProductVariants.xml" hash="bf1315b50d6ef397801821f428b48847"/></dir></target></contents>
|
| 51 |
<compatible/>
|
| 52 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 53 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>xpressbuy_product_variants</name>
|
| 4 |
+
<version>0.0.3</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
| 7 |
<channel>community</channel>
|
| 8 |
<extends/>
|
| 9 |
+
<summary>Commerce Anywhere is a service that allows a retailer to drive in-the-moment purchases of their products.</summary>
|
| 10 |
+
<description>Main purpose of this extension is to support product variants.
|
| 11 |
+

|
| 12 |
+
- It is not possible to get the associated products of Configurable products. Each associated product is listed again as another completely different product.
|
| 13 |
+
- This extension exposes methods which allows extension users to get variants of configurable products.
|
| 14 |
+
- Which makes it easy for customer to select product options (color, size etc.) during 'Add to Cart'.
|
| 15 |
+
- User will have choice to choose various product variants.</description>
|
| 16 |
+
<notes>Changes to getting attributes for configurable products.</notes>
|
| 17 |
+
<authors><author><name>Xpressbuy Inc.</name><user>xpressbuy</user><email>mag@getxpressbuy.com</email></author></authors>
|
| 18 |
+
<date>2016-05-23</date>
|
| 19 |
+
<time>23:37:59</time>
|
| 20 |
+
<contents><target name="magelocal"><dir name="Xpressbuy"><dir name="ProductVariants"><dir name="Model"><file name="Api.php" hash="c26d387ca58d143d2b9e023287be10b8"/></dir><file name="changelog.txt" hash="0323976e773bdb3f62922e11222d0ff1"/><dir name="etc"><file name="api.xml" hash="74ff86f7267809f463c02193a5de32f2"/><file name="config.xml" hash="7085bf73362265779d4880b693859b1a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="XpressBuy_ProductVariants.xml" hash="bf1315b50d6ef397801821f428b48847"/></dir></target></contents>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
<compatible/>
|
| 22 |
<dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
|
| 23 |
</package>
|
