xpressbuy_product_variants - Version 0.0.3

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 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
- $otherOptions = array();
31
  foreach ($productAttributeOptions as $productAttribute) {
32
  foreach ($productAttribute['values'] as $attribute) {
33
- $attributeOptions[$productAttribute['label']] = $productAttribute['label'];
34
  $attr = new stdClass();
 
35
  $attr->code = $attribute['value_index'];
36
- $attr->value = $attribute['store_label'];
37
- $attr->type = $productAttribute['label'];
38
- $otherOptions[$attr->code] = $attr;
 
 
 
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, $otherOptions, $prod_options);
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 $prod_options
66
  * @return array
67
  */
68
- public function getVariantProduct($simple_product, $attr_types, $extraOptions, $prod_options)
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
- $prod_options[] = $extraOptions[$attr_code];
 
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
- 'attributes' => $prod_options
 
 
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.2</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>With Xpressbuy ProductVariants retailers can present customers with related products or variants of the current product selected by customer.&#xD;
10
- &#xD;
11
- XpressBuy is a service that allows a retailer to drive in-the-moment purchases of their products. Anywhere a user engages with their brand, shoppers will be able to make purchases without having to go to the retailer&#x2019;s site. XpressBuy works across all platforms (mobile and desktop), social networks (including Facebook and Twitter), within Apps, within e-mails, and in all types of Advertising (native ads, banner, video, etc.). Allowing buying &#x201C;in-the-moment&#x201D; drives higher conversion rates and, thus, higher ROI. Keeping the user &#x201C;in-the-moment&#x201D; while simultaneously lowering barriers to purchase (such as automatically retrieving address information from the user&#x2019;s mobile carrier), drives conversion rates higher by 2X to 6X and drives up average order value by up to 74%.</summary>
12
- <description>XpressBuy Product Variants&#xD;
13
- &#xD;
14
- With Xpressbuy ProductVariants retailers can present customers with related products or variants of the current product selected by customer.&#xD;
15
- &#xD;
16
- XpressBuy is a service that allows a retailer to drive in-the-moment purchases of their products. Anywhere a user engages with their brand, shoppers will be able to make purchases without having to go to the retailer&#x2019;s site. XpressBuy works across all platforms (mobile and desktop), social networks (including Facebook and Twitter), within Apps, within e-mails, and in all types of Advertising (native ads, banner, video, etc.). Allowing buying &#x201C;in-the-moment&#x201D; drives higher conversion rates and, thus, higher ROI. Keeping the user &#x201C;in-the-moment&#x201D; while simultaneously lowering barriers to purchase (such as automatically retrieving address information from the user&#x2019;s mobile carrier), drives conversion rates higher by 2X to 6X and drives up average order value by up to 74%.&#xD;
17
- &#xD;
18
- Features&#xD;
19
- &#xD;
20
- Product Data to XpressBuy&#xD;
21
- Xpressbuy leverages the Magento&#x2019;s Product API to retrieve product variants and related products. This information is displayed to the user to as part of XpressBuy checkout.&#xD;
22
- &#xD;
23
- Basket Creation in Magento&#xD;
24
- XpressBuy uses this extension to create orders that include shipping, billing, quantity and selected product variants (product id).&#xD;
25
- &#xD;
26
- How it works&#xD;
27
- &#xD;
28
- Xpressbuy retrieves product variants and related products&#xD;
29
- Customer adds these products to cart&#xD;
30
- Upon customer checkout Xpressbuy creates order with selected products and variants.&#xD;
31
- Merchant Benefits&#xD;
32
- &#xD;
33
- Related products:&#xD;
34
- Showing related products to customer will reduce the customer burden to search for them.&#xD;
35
- &#xD;
36
- Increased sales:&#xD;
37
- Relevant products at correct time means more sales total.&#xD;
38
- &#xD;
39
- Customer Benefits:&#xD;
40
- &#xD;
41
- Choice:&#xD;
42
- User will have choice to choose which product to buy(which color or size)&#xD;
43
- &#xD;
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&#xD;
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.&#xD;
11
+ &#xD;
12
+ - It is not possible to get the associated products of Configurable products. Each associated product is listed again as another completely different product.&#xD;
13
+ - This extension exposes methods which allows extension users to get variants of configurable products.&#xD;
14
+ - Which makes it easy for customer to select product options (color, size etc.) during 'Add to Cart'.&#xD;
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>