Version Notes
Plugin corresponds to version 6.0.2 of the Bazaarvoice platform
Download this release
Release Info
Developer | BV DTS |
Extension | Bazaarvoice_Connector |
Version | 6.1.0 |
Comparing to | |
See all releases |
Code changes from version 6.0.6 to 6.1.0
- app/code/local/Bazaarvoice/Connector/Block/Roi/Beacon.php +23 -4
- app/code/local/Bazaarvoice/Connector/Helper/Data.php +9 -7
- app/code/local/Bazaarvoice/Connector/Model/ExportPurchaseFeed.php +28 -4
- app/code/local/Bazaarvoice/Connector/Model/ProductFeed/Product.php +118 -10
- app/code/local/Bazaarvoice/Connector/etc/config.xml +9 -1
- app/code/local/Bazaarvoice/Connector/etc/system.xml +11 -0
- app/design/frontend/enterprise/default/template/bazaarvoice/display/headerproduct.phtml +40 -0
- lib/Bazaarvoice/bvseosdk.php +140 -40
- package.xml +4 -4
app/code/local/Bazaarvoice/Connector/Block/Roi/Beacon.php
CHANGED
@@ -34,7 +34,7 @@ class Bazaarvoice_Connector_Block_Roi_Beacon extends Mage_Core_Block_Template
|
|
34 |
{
|
35 |
$address = $order->getBillingAddress();
|
36 |
|
37 |
-
$orderDetails['orderId'] = $order->
|
38 |
$orderDetails['tax'] = number_format($order->getTaxAmount(), 2, '.', '');
|
39 |
$orderDetails['shipping'] = number_format($order->getShippingAmount(), 2, '.', '');
|
40 |
$orderDetails['total'] = number_format($order->getGrandTotal(), 2, '.', '');
|
@@ -44,10 +44,18 @@ class Bazaarvoice_Connector_Block_Roi_Beacon extends Mage_Core_Block_Template
|
|
44 |
$orderDetails['currency'] = $order->getOrderCurrencyCode();
|
45 |
|
46 |
$orderDetails['items'] = array();
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
48 |
foreach ($items as $itemId => $item)
|
49 |
{
|
|
|
|
|
50 |
$product = Mage::helper('bazaarvoice')->getReviewableProductFromOrderItem($item);
|
|
|
51 |
|
52 |
$itemDetails = array();
|
53 |
$itemDetails['sku'] = Mage::helper('bazaarvoice')->getProductId($product);
|
@@ -57,6 +65,17 @@ class Bazaarvoice_Connector_Block_Roi_Beacon extends Mage_Core_Block_Template
|
|
57 |
$itemDetails['quantity'] = number_format($item->getQtyOrdered(), 0);
|
58 |
$itemDetails['imageUrl'] = $product->getImageUrl();
|
59 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
60 |
array_push($orderDetails['items'], $itemDetails);
|
61 |
}
|
62 |
|
@@ -70,8 +89,8 @@ class Bazaarvoice_Connector_Block_Roi_Beacon extends Mage_Core_Block_Template
|
|
70 |
$orderDetails['partnerSource'] = 'Magento Extension r' . Mage::helper('bazaarvoice')->getExtensionVersion();
|
71 |
}
|
72 |
}
|
73 |
-
|
74 |
$orderDetailsJson = Mage::helper('core')->jsonEncode($orderDetails);
|
75 |
return urldecode(stripslashes($orderDetailsJson));
|
76 |
}
|
77 |
-
}
|
34 |
{
|
35 |
$address = $order->getBillingAddress();
|
36 |
|
37 |
+
$orderDetails['orderId'] = $order->getIncrementId();
|
38 |
$orderDetails['tax'] = number_format($order->getTaxAmount(), 2, '.', '');
|
39 |
$orderDetails['shipping'] = number_format($order->getShippingAmount(), 2, '.', '');
|
40 |
$orderDetails['total'] = number_format($order->getGrandTotal(), 2, '.', '');
|
44 |
$orderDetails['currency'] = $order->getOrderCurrencyCode();
|
45 |
|
46 |
$orderDetails['items'] = array();
|
47 |
+
// if families are enabled, get all items
|
48 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families')){
|
49 |
+
$items = $order->getAllItems();
|
50 |
+
} else {
|
51 |
+
$items = $order->getAllVisibleItems();
|
52 |
+
}
|
53 |
foreach ($items as $itemId => $item)
|
54 |
{
|
55 |
+
// skip configurable items if families are enabled
|
56 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families') && $item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) continue;
|
57 |
$product = Mage::helper('bazaarvoice')->getReviewableProductFromOrderItem($item);
|
58 |
+
$product = Mage::getModel('catalog/product')->load($product->getId());
|
59 |
|
60 |
$itemDetails = array();
|
61 |
$itemDetails['sku'] = Mage::helper('bazaarvoice')->getProductId($product);
|
65 |
$itemDetails['quantity'] = number_format($item->getQtyOrdered(), 0);
|
66 |
$itemDetails['imageUrl'] = $product->getImageUrl();
|
67 |
|
68 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families')) {
|
69 |
+
if(strpos($itemDetails['imageUrl'], "placeholder/image.jpg")) {
|
70 |
+
// if product families are enabled and product has no image, use configurable image
|
71 |
+
$parentId = $item->getParentItem()->getProductId();
|
72 |
+
$parent = Mage::getModel('catalog/product')->load($parentId);
|
73 |
+
$itemDetails['imageUrl'] = $parent->getImageUrl();
|
74 |
+
}
|
75 |
+
// also get price from parent item
|
76 |
+
$itemDetails['price'] = number_format($item->getParentItem()->getPrice(), 2, '.', '');
|
77 |
+
}
|
78 |
+
|
79 |
array_push($orderDetails['items'], $itemDetails);
|
80 |
}
|
81 |
|
89 |
$orderDetails['partnerSource'] = 'Magento Extension r' . Mage::helper('bazaarvoice')->getExtensionVersion();
|
90 |
}
|
91 |
}
|
92 |
+
Mage::log($orderDetails);
|
93 |
$orderDetailsJson = Mage::helper('core')->jsonEncode($orderDetails);
|
94 |
return urldecode(stripslashes($orderDetailsJson));
|
95 |
}
|
96 |
+
}
|
app/code/local/Bazaarvoice/Connector/Helper/Data.php
CHANGED
@@ -28,9 +28,9 @@ class Bazaarvoice_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
28 |
$rawProductId = $product->getSku();
|
29 |
|
30 |
// >> Customizations go here
|
31 |
-
|
32 |
// << No further customizations after this
|
33 |
-
|
34 |
return $this->replaceIllegalCharacters($rawProductId);
|
35 |
|
36 |
}
|
@@ -464,12 +464,14 @@ class Bazaarvoice_Connector_Helper_Data extends Mage_Core_Helper_Abstract
|
|
464 |
if ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)
|
465 |
{
|
466 |
$options = $item->getProductOptions();
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
|
|
|
|
|
|
471 |
}
|
472 |
-
catch (Exception $ex) {}
|
473 |
}
|
474 |
|
475 |
return $product;
|
28 |
$rawProductId = $product->getSku();
|
29 |
|
30 |
// >> Customizations go here
|
31 |
+
$rawProductId = preg_replace_callback('/\./s', create_function('$match','return "_bv".ord($match[0])."_";'), $rawProductId);
|
32 |
// << No further customizations after this
|
33 |
+
|
34 |
return $this->replaceIllegalCharacters($rawProductId);
|
35 |
|
36 |
}
|
464 |
if ($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE)
|
465 |
{
|
466 |
$options = $item->getProductOptions();
|
467 |
+
if(isset($options['super_product_config']['product_id'])){
|
468 |
+
try
|
469 |
+
{
|
470 |
+
$parentId = $options['super_product_config']['product_id'];
|
471 |
+
$product = Mage::getModel('catalog/product')->load($parentId);
|
472 |
+
}
|
473 |
+
catch (Exception $ex) {}
|
474 |
}
|
|
|
475 |
}
|
476 |
|
477 |
return $product;
|
app/code/local/Bazaarvoice/Connector/Model/ExportPurchaseFeed.php
CHANGED
@@ -468,8 +468,17 @@ class Bazaarvoice_Connector_Model_ExportPurchaseFeed extends Mage_Core_Model_Abs
|
|
468 |
$ioObject->streamWrite(' <TransactionDate>' . $this->getTriggeringEventDate($order, $triggeringEvent) .
|
469 |
"</TransactionDate>\n");
|
470 |
$ioObject->streamWrite(" <Products>\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
471 |
/* @var $item Mage_Sales_Model_Order_Item */
|
472 |
-
foreach ($
|
|
|
|
|
|
|
473 |
$product = $bvHelper->getReviewableProductFromOrderItem($item);
|
474 |
if (!is_null($product)) {
|
475 |
$ioObject->streamWrite(" <Product>\n");
|
@@ -477,8 +486,23 @@ class Bazaarvoice_Connector_Model_ExportPurchaseFeed extends Mage_Core_Model_Abs
|
|
477 |
"</ExternalId>\n");
|
478 |
$ioObject->streamWrite(' <Name>' . htmlspecialchars($product->getName(), ENT_QUOTES, 'UTF-8') .
|
479 |
"</Name>\n");
|
480 |
-
|
481 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
482 |
$ioObject->streamWrite(" </Product>\n");
|
483 |
}
|
484 |
}
|
@@ -496,7 +520,7 @@ class Bazaarvoice_Connector_Model_ExportPurchaseFeed extends Mage_Core_Model_Abs
|
|
496 |
|
497 |
private function orderToString(Mage_Sales_Model_Order $order)
|
498 |
{
|
499 |
-
return "\nOrder {Id: " . $order->
|
500 |
. "\n\tCustomerId: " . $order->getCustomerId()
|
501 |
. "\n\tStatus: " . $order->getStatus()
|
502 |
. "\n\tState: " . $order->getState()
|
468 |
$ioObject->streamWrite(' <TransactionDate>' . $this->getTriggeringEventDate($order, $triggeringEvent) .
|
469 |
"</TransactionDate>\n");
|
470 |
$ioObject->streamWrite(" <Products>\n");
|
471 |
+
// if families are enabled, get all items
|
472 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families')){
|
473 |
+
$items = $order->getAllItems();
|
474 |
+
} else {
|
475 |
+
$items = $order->getAllVisibleItems();
|
476 |
+
}
|
477 |
/* @var $item Mage_Sales_Model_Order_Item */
|
478 |
+
foreach ($items as $item) {
|
479 |
+
// skip configurable items if families are enabled
|
480 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families') && $item->getProduct()->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE) continue;
|
481 |
+
|
482 |
$product = $bvHelper->getReviewableProductFromOrderItem($item);
|
483 |
if (!is_null($product)) {
|
484 |
$ioObject->streamWrite(" <Product>\n");
|
486 |
"</ExternalId>\n");
|
487 |
$ioObject->streamWrite(' <Name>' . htmlspecialchars($product->getName(), ENT_QUOTES, 'UTF-8') .
|
488 |
"</Name>\n");
|
489 |
+
|
490 |
+
$imageUrl = $product->getImageUrl();
|
491 |
+
$originalPrice = $item->getOriginalPrice();
|
492 |
+
if(Mage::getStoreConfig('bazaarvoice/feeds/families')) {
|
493 |
+
$parentItem = $item->getParentItem();
|
494 |
+
$parent = Mage::getModel('catalog/product')->load($parentItem->getProductId());
|
495 |
+
|
496 |
+
if(strpos($imageUrl, "placeholder/image.jpg")){
|
497 |
+
// if product families are enabled and product has no image, use configurable image
|
498 |
+
$imageUrl = $parent->getImageUrl();
|
499 |
+
}
|
500 |
+
// also get price from parent item
|
501 |
+
$originalPrice = $parentItem->getOriginalPrice();
|
502 |
+
}
|
503 |
+
|
504 |
+
$ioObject->streamWrite(' <ImageUrl>' . $imageUrl . "</ImageUrl>\n");
|
505 |
+
$ioObject->streamWrite(' <Price>' . number_format((float)$originalPrice, 2) . "</Price>\n");
|
506 |
$ioObject->streamWrite(" </Product>\n");
|
507 |
}
|
508 |
}
|
520 |
|
521 |
private function orderToString(Mage_Sales_Model_Order $order)
|
522 |
{
|
523 |
+
return "\nOrder {Id: " . $order->getIncrementId()
|
524 |
. "\n\tCustomerId: " . $order->getCustomerId()
|
525 |
. "\n\tStatus: " . $order->getStatus()
|
526 |
. "\n\tState: " . $order->getState()
|
app/code/local/Bazaarvoice/Connector/Model/ProductFeed/Product.php
CHANGED
@@ -29,8 +29,7 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
29 |
$productIds->addWebsiteFilter($website->getId());
|
30 |
// Filter collection for product status
|
31 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
32 |
-
|
33 |
-
$productIds->addAttributeToFilter('visibility', array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
34 |
|
35 |
// Output tag only if more than 1 product
|
36 |
if (count($productIds) > 0) {
|
@@ -51,6 +50,21 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
51 |
$product->setStoreId($store->getId());
|
52 |
// Load product object
|
53 |
$product->load($productId->getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
// Set localized product and image url
|
55 |
$product->setData('localized_image_url', $this->getProductImageUrl($product));
|
56 |
// Set bazaarvoice specific attributes
|
@@ -97,9 +111,6 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
97 |
$productIds->addWebsiteFilter($group->getWebsiteId());
|
98 |
// Filter collection for product status
|
99 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
100 |
-
// Filter collection for product visibility
|
101 |
-
$productIds->addAttributeToFilter('visibility',
|
102 |
-
array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
103 |
|
104 |
// Output tag only if more than 1 product
|
105 |
if (count($productIds) > 0) {
|
@@ -120,6 +131,22 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
120 |
$product->setStoreId($store->getId());
|
121 |
// Load product object
|
122 |
$product->load($productId->getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
123 |
// Set localized product and image url
|
124 |
$product->setData('localized_image_url', $this->getProductImageUrl($product));
|
125 |
// Set bazaarvoice specific attributes
|
@@ -164,9 +191,12 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
164 |
$productIds->addWebsiteFilter($store->getWebsiteId());
|
165 |
// Filter collection for product status
|
166 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
167 |
-
|
168 |
-
|
169 |
-
|
|
|
|
|
|
|
170 |
|
171 |
// Output tag only if more than 1 product
|
172 |
if (count($productIds) > 0) {
|
@@ -182,6 +212,10 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
182 |
$productDefault->setStoreId($store->getId());
|
183 |
// Load product object
|
184 |
$productDefault->load($productId->getId());
|
|
|
|
|
|
|
|
|
185 |
// Set localized product and image url
|
186 |
$productDefault->setData('localized_image_url', $this->getProductImageUrl($productDefault));
|
187 |
// Set bazaarvoice specific attributes
|
@@ -234,7 +268,17 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
234 |
}
|
235 |
|
236 |
/* Make sure that CategoryExternalId is one written to Category section */
|
237 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
if (!is_null($parentCategories) && count($parentCategories) > 0) {
|
239 |
foreach ($parentCategories as $parentCategoryId) {
|
240 |
$parentCategory = Mage::getModel('catalog/category')->load($parentCategoryId);
|
@@ -248,6 +292,11 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
248 |
}
|
249 |
}
|
250 |
}
|
|
|
|
|
|
|
|
|
|
|
251 |
|
252 |
$ioObject->streamWrite(' <ProductPageUrl>' . "<![CDATA[" . $this->getProductUrl($productDefault) . "]]>" . "</ProductPageUrl>\n");
|
253 |
$imageUrl = $productDefault->getData('localized_image_url');
|
@@ -286,10 +335,51 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
286 |
}
|
287 |
}
|
288 |
$ioObject->streamWrite(" </ImageUrls>\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
|
290 |
// Close this product
|
291 |
$ioObject->streamWrite("</Product>\n");
|
292 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
|
294 |
protected function getProductImageUrl(Mage_Catalog_Model_Product $product)
|
295 |
{
|
@@ -300,6 +390,13 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
300 |
$storeId = $product->getStoreId();
|
301 |
// Get image url from helper (this is for the default store
|
302 |
$defaultStoreImageUrl = Mage::helper('catalog/image')->init($product, 'image');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
303 |
// Get media base url for correct store
|
304 |
$mediaBaseUrl = Mage::app()->getStore($storeId)->getBaseUrl('media');
|
305 |
// Get default media base url
|
@@ -320,7 +417,18 @@ class Bazaarvoice_Connector_Model_ProductFeed_Product extends Mage_Core_Model_Ab
|
|
320 |
|
321 |
protected function getProductUrl(Mage_Catalog_Model_Product $product)
|
322 |
{
|
323 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
324 |
// Trim any url params
|
325 |
$questionMarkPos = strpos($productUrl, '?');
|
326 |
if($questionMarkPos !== FALSE) {
|
29 |
$productIds->addWebsiteFilter($website->getId());
|
30 |
// Filter collection for product status
|
31 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
32 |
+
|
|
|
33 |
|
34 |
// Output tag only if more than 1 product
|
35 |
if (count($productIds) > 0) {
|
50 |
$product->setStoreId($store->getId());
|
51 |
// Load product object
|
52 |
$product->load($productId->getId());
|
53 |
+
// Product families
|
54 |
+
if (Mage::getStoreConfig('bazaarvoice/feeds/families', $store->getId())) {
|
55 |
+
$product->setData("product_families", $this->getProductFamilies($product));
|
56 |
+
} else {
|
57 |
+
// if families are disabled, skip not visible products
|
58 |
+
if($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
|
59 |
+
if ($website->getDefaultGroup()->getDefaultStoreId() == $store->getId()) {
|
60 |
+
// if default store/group skip entire product
|
61 |
+
continue 2;
|
62 |
+
} else {
|
63 |
+
// else just skip store
|
64 |
+
continue;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
// Set localized product and image url
|
69 |
$product->setData('localized_image_url', $this->getProductImageUrl($product));
|
70 |
// Set bazaarvoice specific attributes
|
111 |
$productIds->addWebsiteFilter($group->getWebsiteId());
|
112 |
// Filter collection for product status
|
113 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
|
|
|
|
|
|
114 |
|
115 |
// Output tag only if more than 1 product
|
116 |
if (count($productIds) > 0) {
|
131 |
$product->setStoreId($store->getId());
|
132 |
// Load product object
|
133 |
$product->load($productId->getId());
|
134 |
+
// Product families
|
135 |
+
if (Mage::getStoreConfig('bazaarvoice/feeds/families', $store->getId())) {
|
136 |
+
$product->setData("product_families", $this->getProductFamilies($product));
|
137 |
+
} else {
|
138 |
+
// if families are disabled, skip not visible products
|
139 |
+
if($product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE) {
|
140 |
+
if ($group->getDefaultStoreId() == $store->getId()) {
|
141 |
+
// if default store, skip entire product
|
142 |
+
continue 2;
|
143 |
+
} else {
|
144 |
+
// just skip store
|
145 |
+
continue;
|
146 |
+
}
|
147 |
+
|
148 |
+
}
|
149 |
+
}
|
150 |
// Set localized product and image url
|
151 |
$product->setData('localized_image_url', $this->getProductImageUrl($product));
|
152 |
// Set bazaarvoice specific attributes
|
191 |
$productIds->addWebsiteFilter($store->getWebsiteId());
|
192 |
// Filter collection for product status
|
193 |
$productIds->addAttributeToFilter('status', Mage_Catalog_Model_Product_Status::STATUS_ENABLED);
|
194 |
+
if (Mage::getStoreConfig('bazaarvoice/feeds/families', $store->getId()) == false) {
|
195 |
+
// Filter collection for product visibility
|
196 |
+
// if families are disabled
|
197 |
+
$productIds->addAttributeToFilter('visibility',
|
198 |
+
array('neq' => Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE));
|
199 |
+
}
|
200 |
|
201 |
// Output tag only if more than 1 product
|
202 |
if (count($productIds) > 0) {
|
212 |
$productDefault->setStoreId($store->getId());
|
213 |
// Load product object
|
214 |
$productDefault->load($productId->getId());
|
215 |
+
// Product families
|
216 |
+
if (Mage::getStoreConfig('bazaarvoice/feeds/families', $store->getId())) {
|
217 |
+
$productDefault->setData("product_families", $this->getProductFamilies($productDefault));
|
218 |
+
}
|
219 |
// Set localized product and image url
|
220 |
$productDefault->setData('localized_image_url', $this->getProductImageUrl($productDefault));
|
221 |
// Set bazaarvoice specific attributes
|
268 |
}
|
269 |
|
270 |
/* Make sure that CategoryExternalId is one written to Category section */
|
271 |
+
if($productDefault->getData("product_families") && $productDefault->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE){
|
272 |
+
// if families are enabled and product is not visible, use parent categories
|
273 |
+
$parentId = array_pop($productDefault->getData("product_families"));
|
274 |
+
$parentProduct = $bvHelper->getProductFromProductExternalId($parentId);
|
275 |
+
$parentCategories = $parentProduct->getCategoryIds();
|
276 |
+
Mage::log("Product ".$productDefault->getSku()." using parent categories from ".$parentProduct->getSku());
|
277 |
+
} else {
|
278 |
+
// normal behavior
|
279 |
+
$parentCategories = $productDefault->getCategoryIds();
|
280 |
+
Mage::log("Product ".$productDefault->getSku()." using its own categories");
|
281 |
+
}
|
282 |
if (!is_null($parentCategories) && count($parentCategories) > 0) {
|
283 |
foreach ($parentCategories as $parentCategoryId) {
|
284 |
$parentCategory = Mage::getModel('catalog/category')->load($parentCategoryId);
|
292 |
}
|
293 |
}
|
294 |
}
|
295 |
+
|
296 |
+
$upcAttribute = Mage::getStoreConfig("bazaarvoice/bv_config/product_feed_upc_attribute_code");
|
297 |
+
if($upcAttribute && $productDefault->getData($upcAttribute)) {
|
298 |
+
$ioObject->streamWrite(' <UPCs><UPC>' . $productDefault->getData($upcAttribute) . "</UPC></UPCs>\n");
|
299 |
+
}
|
300 |
|
301 |
$ioObject->streamWrite(' <ProductPageUrl>' . "<![CDATA[" . $this->getProductUrl($productDefault) . "]]>" . "</ProductPageUrl>\n");
|
302 |
$imageUrl = $productDefault->getData('localized_image_url');
|
335 |
}
|
336 |
}
|
337 |
$ioObject->streamWrite(" </ImageUrls>\n");
|
338 |
+
// Product Families
|
339 |
+
if($productDefault->getData("product_families")){
|
340 |
+
$ioObject->streamWrite(" <Attributes>\n");
|
341 |
+
foreach($productDefault->getData("product_families") as $family){
|
342 |
+
$ioObject->streamWrite(' <Attribute id="BV_FE_FAMILY"><Value>'.$family.'</Value></Attribute>'."\n");
|
343 |
+
}
|
344 |
+
if($productDefault->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE || Mage::getStoreConfig("bazaarvoice/bv_config/product_feed_export_bvfamilies_expand") == 'true'){
|
345 |
+
$ioObject->streamWrite(' <Attribute id="BV_FE_EXPAND">'."\n");
|
346 |
+
foreach($productDefault->getData("product_families") as $family){
|
347 |
+
$ioObject->streamWrite(' <Value>BV_FE_FAMILY:'.$family.'</Value>'."\n");
|
348 |
+
}
|
349 |
+
$ioObject->streamWrite(" </Attribute>\n");
|
350 |
+
}
|
351 |
+
$ioObject->streamWrite(" </Attributes>\n");
|
352 |
+
}
|
353 |
|
354 |
// Close this product
|
355 |
$ioObject->streamWrite("</Product>\n");
|
356 |
}
|
357 |
+
|
358 |
+
protected function getProductFamilies(Mage_Catalog_Model_Product $product)
|
359 |
+
{
|
360 |
+
/* @var $bvHelper Bazaarvoice_Connector_Helper_Data */
|
361 |
+
$bvHelper = Mage::helper('bazaarvoice');
|
362 |
+
$families = array();
|
363 |
+
try {
|
364 |
+
if($product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE){
|
365 |
+
$families[] = $bvHelper->getProductId($product);
|
366 |
+
} else {
|
367 |
+
$parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')->getParentIdsByChild($product->getId());
|
368 |
+
foreach($parentIds as $parentId){
|
369 |
+
$parent = Mage::getModel("catalog/product")->load($parentId);
|
370 |
+
if($parent->getId()){
|
371 |
+
$families[] = $bvHelper->getProductId($parent);
|
372 |
+
}
|
373 |
+
}
|
374 |
+
}
|
375 |
+
}
|
376 |
+
catch (Exception $e) {
|
377 |
+
Mage::log('Failed to get families for product sku: ' . $product->getSku());
|
378 |
+
Mage::log($e->getMessage()."\n".$e->getTraceAsString());
|
379 |
+
Mage::log('Continuing generating feed.');
|
380 |
+
}
|
381 |
+
return $families;
|
382 |
+
}
|
383 |
|
384 |
protected function getProductImageUrl(Mage_Catalog_Model_Product $product)
|
385 |
{
|
390 |
$storeId = $product->getStoreId();
|
391 |
// Get image url from helper (this is for the default store
|
392 |
$defaultStoreImageUrl = Mage::helper('catalog/image')->init($product, 'image');
|
393 |
+
if($product->getData("product_families") && strpos($defaultStoreImageUrl, "placeholder/image.jpg")){
|
394 |
+
// if product families are enabled and product has no image, use configurable image
|
395 |
+
$parents = $product->getData("product_families");
|
396 |
+
$parentId = array_pop($parents);
|
397 |
+
$parent = Mage::helper("bazaarvoice")->getProductFromProductExternalId($parentId);
|
398 |
+
$defaultStoreImageUrl = Mage::helper('catalog/image')->init($parent, 'image');
|
399 |
+
}
|
400 |
// Get media base url for correct store
|
401 |
$mediaBaseUrl = Mage::app()->getStore($storeId)->getBaseUrl('media');
|
402 |
// Get default media base url
|
417 |
|
418 |
protected function getProductUrl(Mage_Catalog_Model_Product $product)
|
419 |
{
|
420 |
+
if($product->getData("product_families") && $product->getVisibility() == Mage_Catalog_Model_Product_Visibility::VISIBILITY_NOT_VISIBLE){
|
421 |
+
// if product families are enabled and product is not visible,
|
422 |
+
// look for its configurable and use that url
|
423 |
+
$parents = $product->getData("product_families");
|
424 |
+
$parentId = array_pop($parents);
|
425 |
+
$parent = Mage::helper("bazaarvoice")->getProductFromProductExternalId($parentId);
|
426 |
+
$parent->setStoreId($product->getStoreId());
|
427 |
+
$productUrl = $parent->getProductUrl(false);
|
428 |
+
} else {
|
429 |
+
// otherwise use default
|
430 |
+
$productUrl = $product->getProductUrl(false);
|
431 |
+
}
|
432 |
// Trim any url params
|
433 |
$questionMarkPos = strpos($productUrl, '?');
|
434 |
if($questionMarkPos !== FALSE) {
|
app/code/local/Bazaarvoice/Connector/etc/config.xml
CHANGED
@@ -8,7 +8,7 @@
|
|
8 |
<config>
|
9 |
<modules>
|
10 |
<Bazaarvoice_Connector>
|
11 |
-
<version>6.0
|
12 |
<depends>
|
13 |
<!-- no dependencies -->
|
14 |
</depends>
|
@@ -125,6 +125,7 @@
|
|
125 |
</qa>
|
126 |
<feeds>
|
127 |
<enable_product_feed>1</enable_product_feed>
|
|
|
128 |
<enable_purchase_feed>1</enable_purchase_feed>
|
129 |
<triggering_event>shipping</triggering_event>
|
130 |
<generation_scope>website</generation_scope>
|
@@ -141,6 +142,13 @@
|
|
141 |
The following attribute code will be used to locate the brand of products
|
142 |
which is sent in the product feed: -->
|
143 |
<product_feed_brand_attribute_code></product_feed_brand_attribute_code>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
|
145 |
<!-- If true, use Magento category URL path as category id, otherwise use Mage category entity primary key -->
|
146 |
<category_id_use_url_path>true</category_id_use_url_path>
|
8 |
<config>
|
9 |
<modules>
|
10 |
<Bazaarvoice_Connector>
|
11 |
+
<version>6.1.0</version>
|
12 |
<depends>
|
13 |
<!-- no dependencies -->
|
14 |
</depends>
|
125 |
</qa>
|
126 |
<feeds>
|
127 |
<enable_product_feed>1</enable_product_feed>
|
128 |
+
<families>0</families>
|
129 |
<enable_purchase_feed>1</enable_purchase_feed>
|
130 |
<triggering_event>shipping</triggering_event>
|
131 |
<generation_scope>website</generation_scope>
|
142 |
The following attribute code will be used to locate the brand of products
|
143 |
which is sent in the product feed: -->
|
144 |
<product_feed_brand_attribute_code></product_feed_brand_attribute_code>
|
145 |
+
<!-- Magento UPC Attribute Code
|
146 |
+
The following attribute code will be used to locate the UPC of products
|
147 |
+
which is sent in the product feed: -->
|
148 |
+
<product_feed_upc_attribute_code></product_feed_upc_attribute_code>
|
149 |
+
<!-- Setting to determine whether simple products show reviews and ratings
|
150 |
+
for their entire product family -->
|
151 |
+
<product_feed_export_bvfamilies_expand>true</product_feed_export_bvfamilies_expand>
|
152 |
|
153 |
<!-- If true, use Magento category URL path as category id, otherwise use Mage category entity primary key -->
|
154 |
<category_id_use_url_path>true</category_id_use_url_path>
|
app/code/local/Bazaarvoice/Connector/etc/system.xml
CHANGED
@@ -249,6 +249,17 @@
|
|
249 |
<show_in_website>1</show_in_website>
|
250 |
<show_in_store>1</show_in_store>
|
251 |
</enable_product_feed>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
252 |
<enable_purchase_feed>
|
253 |
<label>Enable Purchase Feed</label>
|
254 |
<frontend_type>select</frontend_type>
|
249 |
<show_in_website>1</show_in_website>
|
250 |
<show_in_store>1</show_in_store>
|
251 |
</enable_product_feed>
|
252 |
+
<families>
|
253 |
+
<label>Enable BV Product Families</label>
|
254 |
+
<frontend_type>select</frontend_type>
|
255 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
256 |
+
<comment>
|
257 |
+
<![CDATA[BV Product Families will be defined for visible Configurable and Simple product combinations]]></comment>
|
258 |
+
<sort_order>13</sort_order>
|
259 |
+
<show_in_default>1</show_in_default>
|
260 |
+
<show_in_website>1</show_in_website>
|
261 |
+
<show_in_store>1</show_in_store>
|
262 |
+
</families>
|
263 |
<enable_purchase_feed>
|
264 |
<label>Enable Purchase Feed</label>
|
265 |
<frontend_type>select</frontend_type>
|
app/design/frontend/enterprise/default/template/bazaarvoice/display/headerproduct.phtml
CHANGED
@@ -27,4 +27,44 @@ $BV.configure("global", configData);
|
|
27 |
|
28 |
<?php endif; ?>
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
<?php endif; ?>
|
27 |
|
28 |
<?php endif; ?>
|
29 |
|
30 |
+
<?php if(Mage::getStoreConfig('bazaarvoice/feeds/families') && $product->getTypeId() == Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE): ?>
|
31 |
+
<script type="text/javascript">
|
32 |
+
//<![CDATA[
|
33 |
+
<?php
|
34 |
+
$doShowContentJs = Mage::getStoreConfig('bazaarvoice/rr/do_show_content_js');
|
35 |
+
$children = $product->getTypeInstance()->getUsedProducts();
|
36 |
+
$bvIds = array();
|
37 |
+
foreach($children as $child) {
|
38 |
+
$bvIds[$child->getId()] = Mage::helper('bazaarvoice')->getProductId($child);
|
39 |
+
}
|
40 |
+
echo sprintf('var children = %s;', json_encode($bvIds));
|
41 |
+
?>
|
42 |
+
|
43 |
+
(function ($) {
|
44 |
+
|
45 |
+
jQuery('.super-attribute-select').live("change", function(){
|
46 |
+
options = spConfig.config.attributes[jQuery(this).attr('id').replace(/attribute/, '')].options;
|
47 |
+
for(var i in options){
|
48 |
+
if(options[i].id == jQuery(this).val() && children[options[i].products[0]] != undefined){
|
49 |
+
$BV.configure("global", {productId: children[options[i].products[0]]});
|
50 |
+
$BV.ui( 'rr', 'show_reviews', {
|
51 |
+
doShowContent : function () {
|
52 |
+
<?php echo $doShowContentJs ?>
|
53 |
+
}
|
54 |
+
});
|
55 |
+
return;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
$BV.configure("global", {productId: "<?php echo $productId ?>"});
|
59 |
+
$BV.ui( 'rr', 'show_reviews', {
|
60 |
+
doShowContent : function () {
|
61 |
+
<?php echo $doShowContentJs ?>
|
62 |
+
}
|
63 |
+
});
|
64 |
+
});
|
65 |
+
|
66 |
+
}(jQuery));
|
67 |
+
//]]>
|
68 |
+
</script>
|
69 |
+
<?php endif; ?>
|
70 |
<?php endif; ?>
|
lib/Bazaarvoice/bvseosdk.php
CHANGED
@@ -23,10 +23,10 @@
|
|
23 |
* require(bvsdk.php);
|
24 |
*
|
25 |
* $bv = new BV(array(
|
26 |
-
* 'deployment_zone_id' => '
|
27 |
-
* 'product_id' => '
|
28 |
-
* 'cloud_key' => '
|
29 |
-
* 'staging' =>
|
30 |
* ));
|
31 |
*
|
32 |
*/
|
@@ -46,10 +46,10 @@
|
|
46 |
*
|
47 |
* Optional fields
|
48 |
* current_page_url (string) (defaults to detecting the current_page automtically)
|
49 |
-
* staging (boolean) (defaults to
|
50 |
* subject_type (string) (defaults to product, for questions you can pass in categories here if needed)
|
51 |
* latency_timeout (int) (in millseconds) (defaults to 1000ms)
|
52 |
-
* bv_product (string) (defaults to reviews
|
53 |
* bot_list (string) (defualts to msnbot|googlebot|teoma|bingbot|yandexbot|yahoo)
|
54 |
*/
|
55 |
|
@@ -76,15 +76,17 @@ class BV {
|
|
76 |
|
77 |
// config array, defaults are defined here
|
78 |
$this->config = array(
|
79 |
-
'staging' =>
|
80 |
'subject_type' => 'product',
|
81 |
'latency_timeout' => 1000,
|
82 |
-
'current_page_url' => $
|
83 |
-
'
|
|
|
84 |
'include_display_integration_code' => FALSE,
|
85 |
'client_name' => $params['deployment_zone_id'],
|
86 |
'internal_file_path' => FALSE,
|
87 |
'bot_list' => 'msnbot|google|teoma|bingbot|yandexbot|yahoo', // used in regex to determine if request is a bot or not
|
|
|
88 |
);
|
89 |
|
90 |
// merge passed in params with defualts for config.
|
@@ -95,6 +97,8 @@ class BV {
|
|
95 |
|
96 |
// setup the questions object
|
97 |
$this->questions = new Questions($this->config);
|
|
|
|
|
98 |
|
99 |
}
|
100 |
|
@@ -162,6 +166,7 @@ class Base{
|
|
162 |
if ($this->_isBot())
|
163 |
{
|
164 |
|
|
|
165 |
// get the page number of SEO content to load
|
166 |
$page_number = $this->_getPageNumber();
|
167 |
|
@@ -176,21 +181,21 @@ class Base{
|
|
176 |
$seo_content = $this->_replaceTokens($seo_content);
|
177 |
|
178 |
// if debug mode is on we want to include more debug data
|
179 |
-
if (isset($_GET['bvreveal']))
|
180 |
-
{
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
$pay_load
|
190 |
}
|
191 |
else
|
192 |
{
|
193 |
-
$pay_load = $this->_buildComment('
|
194 |
}
|
195 |
|
196 |
return $pay_load;
|
@@ -210,6 +215,7 @@ class Base{
|
|
210 |
* @access private
|
211 |
* @return bool
|
212 |
*/
|
|
|
213 |
private function _isBot()
|
214 |
{
|
215 |
// we need to check the user agent string to see if this is a bot,
|
@@ -236,13 +242,20 @@ class Base{
|
|
236 |
// default to page 1 if a page is not specified in the URL
|
237 |
$page_number = 1;
|
238 |
|
239 |
-
|
240 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
241 |
$page_number = (int) $_GET['bvpage'];
|
242 |
|
243 |
-
// remove the bvpage parameter from the
|
244 |
$seo_param = str_replace('/', '\/', $_GET['bvrrp']); // need to escape slashses for regex
|
245 |
-
$this->config['
|
246 |
}
|
247 |
// other implementations use the bvrrp, bvqap, or bvsyp parameter ?bvrrp=1234-en_us/reviews/product/2/ASF234.htm
|
248 |
else if(isset($_GET['bvrrp']) OR isset($_GET['bvqap']) OR isset($_GET['bvsyp']) ){
|
@@ -258,15 +271,47 @@ class Base{
|
|
258 |
{
|
259 |
$bvparam = $_GET['bvsyp'];
|
260 |
}
|
261 |
-
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
$page_number = max(1, (int) $page_number[1]);
|
264 |
-
|
265 |
-
// remove the bvrrp parameter from the
|
266 |
$seo_param = str_replace('/', '\/', $bvparam); // need to escape slashses for regex
|
267 |
-
$this->config['
|
268 |
}
|
269 |
-
|
270 |
return $page_number;
|
271 |
}// end of _getPageNumber()
|
272 |
|
@@ -378,21 +423,23 @@ class Base{
|
|
378 |
// Close the cURL resource, and free system resources
|
379 |
curl_close($ch);
|
380 |
|
|
|
|
|
381 |
// see if we got any errors with the connection
|
382 |
if($request['error_number'] != 0){
|
383 |
$msg = 'Error - '.$request['error_message'];
|
384 |
-
$this->_buildComment($msg);
|
385 |
}
|
386 |
|
387 |
// see if we got a status code of something other than 200
|
388 |
if($request['info']['http_code'] != 200){
|
389 |
$msg = 'HTTP status code of '.$request['info']['http_code'].' was returned';
|
390 |
-
return $this->_buildComment($msg);
|
391 |
}
|
392 |
|
393 |
// if we are here we got a response so let's return it
|
394 |
-
$
|
395 |
-
return $request['response'].$this->_buildComment($msg);
|
396 |
}
|
397 |
|
398 |
/**
|
@@ -408,7 +455,7 @@ class Base{
|
|
408 |
|
409 |
private function _replaceTokens($content){
|
410 |
// determine if query string exists in current page url
|
411 |
-
if (parse_url($this->config['
|
412 |
// append an amperstand, because the URL already has a ? mark
|
413 |
$page_url_query_prefix = '&';
|
414 |
} else {
|
@@ -416,15 +463,68 @@ class Base{
|
|
416 |
$page_url_query_prefix = '?';
|
417 |
}
|
418 |
|
419 |
-
$content = str_replace('{INSERT_PAGE_URI}', $this->config['
|
420 |
|
421 |
return $content;
|
422 |
}
|
423 |
|
424 |
-
private function _buildComment($msg){
|
425 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
426 |
}
|
427 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
428 |
} // end of Base class
|
429 |
|
430 |
|
@@ -508,4 +608,4 @@ class Questions extends Base{
|
|
508 |
}
|
509 |
} // end of Questions class
|
510 |
|
511 |
-
// end of bvsdk.php
|
23 |
* require(bvsdk.php);
|
24 |
*
|
25 |
* $bv = new BV(array(
|
26 |
+
* 'deployment_zone_id' => '1234-en_US',
|
27 |
+
* 'product_id' => 'XXYYY',
|
28 |
+
* 'cloud_key' => 'company-cdfa682b84bef44672efed074093ccd3',
|
29 |
+
* 'staging' => FALSE
|
30 |
* ));
|
31 |
*
|
32 |
*/
|
46 |
*
|
47 |
* Optional fields
|
48 |
* current_page_url (string) (defaults to detecting the current_page automtically)
|
49 |
+
* staging (boolean) (defaults to false, need to put true for testing with staging data)
|
50 |
* subject_type (string) (defaults to product, for questions you can pass in categories here if needed)
|
51 |
* latency_timeout (int) (in millseconds) (defaults to 1000ms)
|
52 |
+
* bv_product (string) (defaults to reviews)
|
53 |
* bot_list (string) (defualts to msnbot|googlebot|teoma|bingbot|yandexbot|yahoo)
|
54 |
*/
|
55 |
|
76 |
|
77 |
// config array, defaults are defined here
|
78 |
$this->config = array(
|
79 |
+
'staging' => FALSE,
|
80 |
'subject_type' => 'product',
|
81 |
'latency_timeout' => 1000,
|
82 |
+
'current_page_url' => isset($params['current_page_url']) ? $params['current_page_url'] : '', //get the current page url passed in as a "parameter"
|
83 |
+
'base_page_url' => $this->_getCurrentUrl(),
|
84 |
+
'bot_detection' => FALSE, // bot detection should only be enabled if average execution time regularly exceeds 350ms.
|
85 |
'include_display_integration_code' => FALSE,
|
86 |
'client_name' => $params['deployment_zone_id'],
|
87 |
'internal_file_path' => FALSE,
|
88 |
'bot_list' => 'msnbot|google|teoma|bingbot|yandexbot|yahoo', // used in regex to determine if request is a bot or not
|
89 |
+
|
90 |
);
|
91 |
|
92 |
// merge passed in params with defualts for config.
|
97 |
|
98 |
// setup the questions object
|
99 |
$this->questions = new Questions($this->config);
|
100 |
+
|
101 |
+
// setup the timer object
|
102 |
|
103 |
}
|
104 |
|
166 |
if ($this->_isBot())
|
167 |
{
|
168 |
|
169 |
+
|
170 |
// get the page number of SEO content to load
|
171 |
$page_number = $this->_getPageNumber();
|
172 |
|
181 |
$seo_content = $this->_replaceTokens($seo_content);
|
182 |
|
183 |
// if debug mode is on we want to include more debug data
|
184 |
+
//if (isset($_GET['bvreveal']))
|
185 |
+
//{
|
186 |
+
// if($_GET['bvreveal'] == 'debug')
|
187 |
+
// {
|
188 |
+
// $printable_config = $this->config;
|
189 |
+
// $seo_content .= $this->_buildComment('Config options: '.print_r($printable_config, TRUE));
|
190 |
+
// }
|
191 |
+
//}
|
192 |
+
|
193 |
+
$pay_load = $page_number;
|
194 |
+
$pay_load .= $seo_content;
|
195 |
}
|
196 |
else
|
197 |
{
|
198 |
+
$pay_load = $this->_buildComment('JavaScript-only Display','');
|
199 |
}
|
200 |
|
201 |
return $pay_load;
|
215 |
* @access private
|
216 |
* @return bool
|
217 |
*/
|
218 |
+
|
219 |
private function _isBot()
|
220 |
{
|
221 |
// we need to check the user agent string to see if this is a bot,
|
242 |
// default to page 1 if a page is not specified in the URL
|
243 |
$page_number = 1;
|
244 |
|
245 |
+
//parse the current url that's passed in via the parameters
|
246 |
+
$currentUrlArray = parse_url($this->config['current_page_url']);
|
247 |
+
|
248 |
+
$query = $currentUrlArray['path']; //get the path out of the parsed url array
|
249 |
+
|
250 |
+
parse_str($query, $bvcurrentpagedata); //parse the sub url such that you get the important part...page number
|
251 |
+
|
252 |
+
// bvpage is not currently implemented
|
253 |
+
if (isset($_GET['bvpage']) ){
|
254 |
$page_number = (int) $_GET['bvpage'];
|
255 |
|
256 |
+
// remove the bvpage parameter from the base URL so we don't keep appending it
|
257 |
$seo_param = str_replace('/', '\/', $_GET['bvrrp']); // need to escape slashses for regex
|
258 |
+
$this->config['base_page_url'] = preg_replace('/[?&]bvrrp='.$seo_param.'/', '', $this->config['base_page_url']);
|
259 |
}
|
260 |
// other implementations use the bvrrp, bvqap, or bvsyp parameter ?bvrrp=1234-en_us/reviews/product/2/ASF234.htm
|
261 |
else if(isset($_GET['bvrrp']) OR isset($_GET['bvqap']) OR isset($_GET['bvsyp']) ){
|
271 |
{
|
272 |
$bvparam = $_GET['bvsyp'];
|
273 |
}
|
274 |
+
}
|
275 |
+
else if(isset($bvcurrentpagedata)) //if the base url doesn't include the page number information and the current url
|
276 |
+
//is defined then use the data from the current URL.
|
277 |
+
{
|
278 |
+
|
279 |
+
if (isset($bvcurrentpagedata['bvpage']) )
|
280 |
+
{
|
281 |
+
$page_number = (int) $bvcurrentpagedata['bvpage'];
|
282 |
+
$bvparam=$bvcurrentpagedata['bvpage'];
|
283 |
+
// remove the bvpage parameter from the base URL so we don't keep appending it
|
284 |
+
$seo_param = str_replace('/', '\/', $_GET['bvrrp']); // need to escape slashses for regex
|
285 |
+
$this->config['base_page_url'] = preg_replace('/[?&]bvrrp='.$seo_param.'/', '', $this->config['base_page_url']);
|
286 |
+
}
|
287 |
+
// other implementations use the bvrrp, bvqap, or bvsyp parameter ?bvrrp=1234-en_us/reviews/product/2/ASF234.htm
|
288 |
+
else if(isset($bvcurrentpagedata['bvrrp'])
|
289 |
+
|| isset($bvcurrentpagedata['bvqap'])
|
290 |
+
|| isset($bvcurrentpagedata['bvsyp']) )
|
291 |
+
{
|
292 |
+
if(isset($bvcurrentpagedata['bvrrp']))
|
293 |
+
{
|
294 |
+
$bvparam = $bvcurrentpagedata['bvrrp'];
|
295 |
+
}
|
296 |
+
else if(isset($bvcurrentpagedata['bvqap']))
|
297 |
+
{
|
298 |
+
$bvparam = $bvcurrentpagedata['bvqap'];
|
299 |
+
}
|
300 |
+
else
|
301 |
+
{
|
302 |
+
$bvparam = $bvcurrentpagedata['bvsyp'];
|
303 |
+
}
|
304 |
+
}
|
305 |
+
}
|
306 |
+
|
307 |
+
if(isset($bvparam)){
|
308 |
+
preg_match('/\/(\d+?)\/[^\/]+$/', $bvparam, $page_number);
|
309 |
$page_number = max(1, (int) $page_number[1]);
|
310 |
+
|
311 |
+
// remove the bvrrp parameter from the base URL so we don't keep appending it
|
312 |
$seo_param = str_replace('/', '\/', $bvparam); // need to escape slashses for regex
|
313 |
+
$this->config['base_page_url'] = preg_replace('/[?&]bvrrp='.$seo_param.'/', '', $this->config['base_page_url']);
|
314 |
}
|
|
|
315 |
return $page_number;
|
316 |
}// end of _getPageNumber()
|
317 |
|
423 |
// Close the cURL resource, and free system resources
|
424 |
curl_close($ch);
|
425 |
|
426 |
+
$msg="";
|
427 |
+
|
428 |
// see if we got any errors with the connection
|
429 |
if($request['error_number'] != 0){
|
430 |
$msg = 'Error - '.$request['error_message'];
|
431 |
+
$this->_buildComment($msg,$url);
|
432 |
}
|
433 |
|
434 |
// see if we got a status code of something other than 200
|
435 |
if($request['info']['http_code'] != 200){
|
436 |
$msg = 'HTTP status code of '.$request['info']['http_code'].' was returned';
|
437 |
+
return $this->_buildComment($msg,$url);
|
438 |
}
|
439 |
|
440 |
// if we are here we got a response so let's return it
|
441 |
+
$this->response_time = round($request['info']['total_time'] * 1000);
|
442 |
+
return $request['response'].$this->_buildComment($msg,$url);
|
443 |
}
|
444 |
|
445 |
/**
|
455 |
|
456 |
private function _replaceTokens($content){
|
457 |
// determine if query string exists in current page url
|
458 |
+
if (parse_url($this->config['base_page_url'], PHP_URL_QUERY) != ''){
|
459 |
// append an amperstand, because the URL already has a ? mark
|
460 |
$page_url_query_prefix = '&';
|
461 |
} else {
|
463 |
$page_url_query_prefix = '?';
|
464 |
}
|
465 |
|
466 |
+
$content = str_replace('{INSERT_PAGE_URI}', $this->config['base_page_url'] . $page_url_query_prefix, $content);
|
467 |
|
468 |
return $content;
|
469 |
}
|
470 |
|
471 |
+
private function _buildComment($msg,$url){
|
472 |
+
$footer = '<ul id="BVSEOSDK" style="display:none;">';
|
473 |
+
$footer .= "\n".' <li id="vn">bvseo-1.0.1.3-beta</li>';
|
474 |
+
$footer .= "\n".' <li id="sl">bvseo-p</li>';
|
475 |
+
if ($this->config['internal_file_path']) {
|
476 |
+
$footer .= "\n".' <li id="mt">bvseo-FILE</li>';
|
477 |
+
} else {
|
478 |
+
$footer .= "\n".' <li id="mt">bvseo-CLOUD</li>';
|
479 |
+
}
|
480 |
+
if(isset($this->response_time))
|
481 |
+
$footer .= "\n".' <li id="et">bvseo-'.$this->response_time.'ms</li>';
|
482 |
+
$footer .= "\n".' <li id="ct">bvseo-'.strtoupper($this->config['bv_product']).'</li>';
|
483 |
+
$footer .= "\n".' <li id="st">bvseo-'.strtoupper($this->config['subject_type']).'</li>';
|
484 |
+
$footer .= "\n".' <li id="am">bvseo-getContent</li>';
|
485 |
+
if (strlen($msg) > 0) {
|
486 |
+
$footer .= "\n".' <li id="ms">bvseo-msg: '.$msg.'</li>';
|
487 |
+
}
|
488 |
+
$footer .= "\n".'</ul>';
|
489 |
+
|
490 |
+
//when in debug mode, also display the following information
|
491 |
+
if (isset($_GET['bvreveal'])){
|
492 |
+
if($_GET['bvreveal'] == 'debug') {
|
493 |
+
$footer .= "\n".'<ul id="BVSEOSDK_DEBUG" style="display:none;">';
|
494 |
+
$footer .= "\n".' <li id="cloudKey">'.$this->config['cloud_key'].'</li>';
|
495 |
+
$footer .= "\n".' <li id="bv.root.folder">'.$this->config['deployment_zone_id'].'</li>';
|
496 |
+
$footer .= "\n".' <li id="stagingS3Hostname">'.$this->bv_config['seo-domain']['staging'].'</li>';
|
497 |
+
$footer .= "\n".' <li id="productionS3Hostname">'.$this->bv_config['seo-domain']['production'].'</li>';
|
498 |
+
$staging = ($this->config['staging']) ? 'TRUE' : 'FALSE';
|
499 |
+
$footer .= "\n".' <li id="staging">'.$staging.'</li>';
|
500 |
+
$footer .= "\n".' <li id="seo.sdk.execution.timeout">'.$this->config['latency_timeout'].'</li>';
|
501 |
+
$bot_detection = ($this->config['bot_detection']) ? 'TRUE' : 'FALSE';
|
502 |
+
$footer .= "\n".' <li id="botDetection">'.$bot_detection.'</li>';
|
503 |
+
$footer .= "\n".' <li id="crawlerAgentPattern">'.$this->config['bot_list'].'</li>';
|
504 |
+
$footer .= "\n".' <li id="userAgent">'.$_SERVER['HTTP_USER_AGENT'].'</li>';
|
505 |
+
$footer .= "\n".' <li id="pageURI">'.$this->config['current_page_url'].'</li>';
|
506 |
+
$footer .= "\n".' <li id="baseURI">'.$this->config['base_page_url'].'</li>';
|
507 |
+
$footer .= "\n".' <li id="subjectID">'.urlencode($this->config['product_id']).'</li>';
|
508 |
+
$footer .= "\n".' <li id="contentType">'.strtoupper($this->config['bv_product']).'</li>';
|
509 |
+
$footer .= "\n".' <li id="subjectType">'.strtoupper($this->config['subject_type']).'</li>';
|
510 |
+
$footer .= "\n".' <li id="contentURL">'.$url.'</li>';
|
511 |
+
$footer .= "\n".'</ul>';
|
512 |
+
}
|
513 |
+
}
|
514 |
+
|
515 |
+
return $footer;
|
516 |
+
// return "\n".'<!--BVSEO|dp: '.$this->config['deployment_zone_id'].'|sdk: v1.0-p|msg: '.$msg.' -->';
|
517 |
}
|
518 |
|
519 |
+
private function _booleanToString($boolean){
|
520 |
+
if ($boolean){
|
521 |
+
return 'TRUE';
|
522 |
+
}else{
|
523 |
+
return 'FALSE';
|
524 |
+
}
|
525 |
+
}
|
526 |
+
|
527 |
+
|
528 |
} // end of Base class
|
529 |
|
530 |
|
608 |
}
|
609 |
} // end of Questions class
|
610 |
|
611 |
+
// end of bvsdk.php
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Bazaarvoice_Connector</name>
|
4 |
-
<version>6.0
|
5 |
<stability>stable</stability>
|
6 |
<license>Bazaarvoice, Inc.</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>See www.bazaarvoice.com for further details on our offerings</description>
|
11 |
<notes>Plugin corresponds to version 6.0.2 of the Bazaarvoice platform</notes>
|
12 |
<authors><author><name>BV DTS</name><user>bvdts</user><email>dts@bazaarvoice.com</email></author></authors>
|
13 |
-
<date>2014-
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="Bazaarvoice"><dir name="Connector"><dir name="Block"><file name="Bazaarvoice.php" hash="473e92e58fd86c823fb55765ed473414"/><file name="Questions.php" hash="04a7302c66539d17fac4f75b13b2ff2a"/><file name="Ratings.php" hash="6822db584f2ee777beb8d39c662e8465"/><file name="Reviews.php" hash="3eb82792967e70e5fed975521c5b5ceb"/><dir name="Roi"><file name="Beacon.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Bazaarvoice_Connector</name>
|
4 |
+
<version>6.1.0</version>
|
5 |
<stability>stable</stability>
|
6 |
<license>Bazaarvoice, Inc.</license>
|
7 |
<channel>community</channel>
|
10 |
<description>See www.bazaarvoice.com for further details on our offerings</description>
|
11 |
<notes>Plugin corresponds to version 6.0.2 of the Bazaarvoice platform</notes>
|
12 |
<authors><author><name>BV DTS</name><user>bvdts</user><email>dts@bazaarvoice.com</email></author></authors>
|
13 |
+
<date>2014-08-26</date>
|
14 |
+
<time>19:34:17</time>
|
15 |
+
<contents><target name="magelocal"><dir name="Bazaarvoice"><dir name="Connector"><dir name="Block"><file name="Bazaarvoice.php" hash="473e92e58fd86c823fb55765ed473414"/><file name="Questions.php" hash="04a7302c66539d17fac4f75b13b2ff2a"/><file name="Ratings.php" hash="6822db584f2ee777beb8d39c662e8465"/><file name="Reviews.php" hash="3eb82792967e70e5fed975521c5b5ceb"/><dir name="Roi"><file name="Beacon.php" hash="c52c2c56628c64fc044b33903bd00ed6"/></dir><file name="Submissioncontainer.php" hash="23d04ee9ece011d107bb8b914653a24d"/></dir><dir name="Helper"><file name="Data.php" hash="d81bfd736ffc9faf0bbc65adcdc0b609"/></dir><dir name="Model"><file name="ExportProductFeed.php" hash="c6fdc0d37e2384c8fcf4a366e6bf7c2d"/><file name="ExportPurchaseFeed.php" hash="96fd47a1ce7e7f4533340a8f2164c645"/><dir name="Mysql4"><file name="Setup.php" hash="884c886c1e9fa395f05e7872ba6478a2"/></dir><dir name="ProductFeed"><file name="Brand.php" hash="b2ab72e79d7e3afe23b38bc3b64ba115"/><file name="Category.php" hash="c08fe52655879ca6d47caed30c657d7d"/><file name="Product.php" hash="cd665dce7262587638ad7485a05699af"/></dir><file name="RetrieveInlineRatingsFeed.php" hash="d9b5548838a43917de916dbd5266b48a"/><file name="RetrieveSmartSEOPackage.php" hash="eab3badfb13d16965d280ca13109abe6"/><dir name="Source"><file name="AuthenticationMethod.php" hash="582d6c76372bac64728e6e4d68f959e4"/><file name="Environment.php" hash="1e575c9adb480df80e4a8a917960bd55"/><file name="FeedGenerationScope.php" hash="b2450e4c0c69b0da328f1d0d7d67012a"/><file name="TriggeringEvent.php" hash="fa47f3a2fcec92d9603f21541c853035"/></dir></dir><dir name="controllers"><file name="FeedController.php" hash="933a1555d97ac2cec8ea52306cf63102"/><file name="IndexController.php" hash="16b9a353153d40ebc32e759112ca6d6f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="39cf8642bfc219709849618519a1c767"/><file name="config.xml" hash="1f867c512dd1878e80c2de51d236dccc"/><file name="system.xml" hash="efbc1b4d25f09f93d1bba3c012f77f27"/></dir><dir name="sql"><dir name="bazaarvoice_setup"><file name="mysql4-install-0.1.0.php" hash="d721fefe4be8cee31e6bd25b8252dca6"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Bazaarvoice_Connector.xml" hash="c517b52d29fec93a83a8010451368ee1"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="enterprise"><dir name="default"><dir name="template"><dir name="bazaarvoice"><dir name="display"><file name="headerincludes.phtml" hash="0faf96303bfe38e1c4130dfdbaff9c87"/><file name="headerproduct.phtml" hash="b2f48fcb558b33faeb4c6fa0cff7a064"/><dir name="qa"><file name="questions.phtml" hash="b5c186576e9c20cd764860ad08702349"/><file name="questionsummary.phtml" hash="c6044994c1d355730d7e5cfd3a6e3125"/></dir><dir name="rr"><file name="ratings.phtml" hash="56047515b347d0250d44e4e2eb0a923c"/><file name="reviews.phtml" hash="7d2ad8b18910010d22240c9521131290"/><file name="reviewsummary.phtml" hash="75e823088dd75387fc94e6028d8236a5"/></dir></dir><dir name="submit"><file name="roi_beacon.phtml" hash="494b9a44ceb14b1f376611d30ac18645"/><file name="submissioncontainer.phtml" hash="3f3f22b922c1aa5b87f7bbf4fbeea51c"/></dir></dir></dir><dir name="layout"><file name="bazaarvoice.xml" hash="e8d6c4a2ca62a21ddac1cd22e1ee8ad0"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><dir name="template"><dir name="email"><file name="bazaarvoice_notification.html" hash="9a0e90ac62d926dad4db13719f3c8b73"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="bazaarvoice"><file name="rating-0_0.gif" hash="f50bd3f45f69a753614b2e76f53bdafc"/><file name="rating-1_0.gif" hash="c691e11e3250a18939aec523734d9b67"/><file name="rating-1_1.gif" hash="26377f1337bb6fb9e340292243a6f780"/><file name="rating-1_2.gif" hash="5c51583dc52d901c61d9470d5faeb2a4"/><file name="rating-1_3.gif" hash="3948c716d18ea0389ce9e57c347e7b6d"/><file name="rating-1_4.gif" hash="2211d8586bda467cb8fcc617670b94df"/><file name="rating-1_5.gif" hash="3fa9480c8b86f85749147fa0e8144b05"/><file name="rating-1_6.gif" hash="a577c79e7ea0c6c59ac15251c39de515"/><file name="rating-1_7.gif" hash="b5b52fa267632eda6ba5b3be56319397"/><file name="rating-1_8.gif" hash="205170e1ffbfcc81569286a9e1a88eb5"/><file name="rating-1_9.gif" hash="63709f7b2a2e2f14ae442dbef6513f25"/><file name="rating-2_0.gif" hash="4eec2468b5e41dc03d198ed6fe084a53"/><file name="rating-2_1.gif" hash="155cab7b16f4cfef3e94b99ca297cedc"/><file name="rating-2_2.gif" hash="2e2dc606fd83853bdf90a3beb901cf3e"/><file name="rating-2_3.gif" hash="638632f37a750558722c0bf1a79f2546"/><file name="rating-2_4.gif" hash="6b0a85c21066c6402b9f8914284b999f"/><file name="rating-2_5.gif" hash="c4792dac3b9d5a914a72a4200f931c6e"/><file name="rating-2_6.gif" hash="1c7ac3f4e3721d4779721973cfaaa8db"/><file name="rating-2_7.gif" hash="21b680dce6ffef505532afea7fea1452"/><file name="rating-2_8.gif" hash="136ac6b284d1a2b9452a06eea993c1fa"/><file name="rating-2_9.gif" hash="d13af6920569aa85da6dfb0a139d560a"/><file name="rating-3_0.gif" hash="6b30e597cc23aec52dbd2be978d52351"/><file name="rating-3_1.gif" hash="cb544d168a949100fb5ee117adbd765b"/><file name="rating-3_2.gif" hash="75124c4b4dfc5cbcf5ae3ccfa7bdf906"/><file name="rating-3_3.gif" hash="0693b6a471361957da1dc8ee2e9af5ec"/><file name="rating-3_4.gif" hash="1a6e3cff41a61e1bbed9296badb94392"/><file name="rating-3_5.gif" hash="7f63ecf505414386267fad2e92617a9f"/><file name="rating-3_6.gif" hash="8b9b9ccebc3537cffd2bed75c60eaa9e"/><file name="rating-3_7.gif" hash="7f83f3996a738d1fd6763204cd964376"/><file name="rating-3_8.gif" hash="219a1f2dbd45bcb58a58f460c9491bbf"/><file name="rating-3_9.gif" hash="e4114607ca469db2fd5f87ac21c4f00a"/><file name="rating-4_0.gif" hash="a15541525186bf6911202e0f64daa4a6"/><file name="rating-4_1.gif" hash="818971c067beb397247095f5eedbac29"/><file name="rating-4_2.gif" hash="5b9599176771adfbf8c52c7dfa04e565"/><file name="rating-4_3.gif" hash="18dc68db736819e17ab5cf0d5725d99c"/><file name="rating-4_4.gif" hash="56b124f1a2e599918b462ce29cd1cd96"/><file name="rating-4_5.gif" hash="2044f11b1f7005f66f14219c5fce1020"/><file name="rating-4_6.gif" hash="3166f044e7f73f9b3e75bda4507eaa35"/><file name="rating-4_7.gif" hash="20546d3ebee7a364927e9da9274996a7"/><file name="rating-4_8.gif" hash="9dab0f19785d1592a96c5c295842f308"/><file name="rating-4_9.gif" hash="19a47143b04aceae85def246059fba33"/><file name="rating-5_0.gif" hash="e43b403663785255d2f023ca35566ac3"/></dir></dir></dir></dir></dir></target><target name="magelib"><dir name="Bazaarvoice"><file name="bvseosdk.php" hash="1d15f0db486bc571c8f6f7e440a74feb"/></dir></target><target name="mageweb"><dir name="shell"><file name="bv_export_order_feed.php" hash="309995ede2f85d95a0b91d8845c06ae5"/><file name="bv_export_product_feed.php" hash="1696c363c97bf9943560045b297c98fb"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|