Version Notes
No Notes
Download this release
Release Info
| Developer | GoDataFeedSupport |
| Extension | GoDataFeed |
| Version | 1.0.1 |
| Comparing to | |
| See all releases | |
Code changes from version 1.0.0 to 1.0.1
app/code/local/GoDataFeed/Services/Model/Catalog/Product/Api.php
CHANGED
|
@@ -13,12 +13,25 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 13 |
const DESCRIPTION_FIELD = 'description';
|
| 14 |
const SHORT_DESCRIPTION_FIELD = 'short_description';
|
| 15 |
const CATEGORY_NAME_FIELD = 'name';
|
|
|
|
|
|
|
| 16 |
|
| 17 |
const CATEGORY_SEPARATOR = ' > ';
|
| 18 |
|
| 19 |
public function count($filters, $stockQuantityFilterAmount, $store, $responseField)
|
| 20 |
{
|
| 21 |
-
$filteredProductsCollection = $this->getProductsFilteredByStockQuantity(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
$numberOfProducts = 0;
|
| 24 |
if(!empty($filteredProductsCollection)) {
|
|
@@ -57,228 +70,225 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 57 |
$storeId = $this->_getStoreId($store);
|
| 58 |
|
| 59 |
// GET PRODUCTS FOR REQUESTED STORE WITH SPECIFIED FILTERS
|
| 60 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
|
| 62 |
if(!empty($filteredProductsCollection)) {
|
| 63 |
|
| 64 |
-
$
|
| 65 |
|
| 66 |
-
|
| 67 |
-
$filteredProducts[] = $product;
|
| 68 |
-
}
|
| 69 |
|
| 70 |
-
|
| 71 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
|
| 73 |
-
|
| 74 |
-
$
|
|
|
|
|
|
|
|
|
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
|
|
|
| 82 |
|
| 83 |
-
|
|
|
|
|
|
|
| 84 |
|
| 85 |
-
$
|
| 86 |
-
|
| 87 |
-
|
| 88 |
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
}
|
| 99 |
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
$attributeField = $productToRetreive->getResource()->getAttribute($customAttribute);
|
| 105 |
-
|
| 106 |
-
//If it's an option or multiselect attribute
|
| 107 |
-
if(!empty($attributeField) && $attributeField->usesSource() && $productToRetreive->getAttributeText($customAttribute)) {
|
| 108 |
-
$attributeFieldValue = $productToRetreive->getAttributeText($customAttribute);
|
| 109 |
-
}
|
| 110 |
-
else {
|
| 111 |
-
$attributeFieldValue = $productToRetreive->getData($customAttribute);
|
| 112 |
-
}
|
| 113 |
-
|
| 114 |
-
if($scrubCustomAttribute) {
|
| 115 |
-
$attributeFieldValue = $this->scrubData($attributeFieldValue);
|
| 116 |
-
}
|
| 117 |
-
|
| 118 |
-
$resultItem[$customAttribute] = $attributeFieldValue;
|
| 119 |
-
}
|
| 120 |
-
}
|
| 121 |
|
| 122 |
-
|
| 123 |
-
if(in_array(self::PRODUCT_NAME_FIELD, $attributes) && $scrubProductName) {
|
| 124 |
-
$productName = $resultItem[self::PRODUCT_NAME_FIELD];
|
| 125 |
-
$resultItem[self::PRODUCT_NAME_FIELD] = $this->scrubData($productName);
|
| 126 |
-
}
|
| 127 |
|
| 128 |
-
|
| 129 |
-
if(in_array(self::DESCRIPTION_FIELD, $attributes) && $scrubDescription) {
|
| 130 |
-
$resultItem[self::DESCRIPTION_FIELD] =
|
| 131 |
-
$this->scrubData($resultItem[self::DESCRIPTION_FIELD]);
|
| 132 |
-
}
|
| 133 |
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
}
|
| 139 |
|
| 140 |
-
|
| 141 |
-
$
|
| 142 |
-
$
|
| 143 |
-
|
|
|
|
|
|
|
| 144 |
|
| 145 |
-
|
|
|
|
|
|
|
| 146 |
|
| 147 |
-
|
|
|
|
| 148 |
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
}
|
| 159 |
-
}
|
| 160 |
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
|
| 165 |
-
|
| 166 |
-
if (!empty($attributeSet)) {
|
| 167 |
|
| 168 |
-
|
| 169 |
-
if($scrubAttributeSetName) {
|
| 170 |
-
$attributeSetName = $this->scrubData($attributeSetName);
|
| 171 |
-
}
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
}
|
| 176 |
-
}
|
| 177 |
|
| 178 |
-
|
| 179 |
-
$categoryBreadCrumbRequested = $categoryBreadCrumbConfig[0];
|
| 180 |
-
if($categoryBreadCrumbRequested) {
|
| 181 |
-
|
| 182 |
-
$categoryIds = Mage::getResourceSingleton(self::CATALOG_PRODUCT_MODEL)->getCategoryIds($productToRetreive);
|
| 183 |
-
|
| 184 |
-
if (!empty($categoryIds)) {
|
| 185 |
-
|
| 186 |
-
$categoryBreadcrumb = '';
|
| 187 |
-
foreach($categoryIds as $categoryId) {
|
| 188 |
-
|
| 189 |
-
$category = Mage::getModel(self::CATALOG_CATEGORY_MODEL)->setStoreId($storeId)->load($categoryId);
|
| 190 |
-
|
| 191 |
-
if(!empty($category) && $category->getId()) {
|
| 192 |
-
$categoryBreadcrumb .= $category->getData(self::CATEGORY_NAME_FIELD) . self::CATEGORY_SEPARATOR;
|
| 193 |
-
}
|
| 194 |
-
}
|
| 195 |
-
|
| 196 |
-
$categoryBreadcrumb = preg_replace('/' . self::CATEGORY_SEPARATOR . '$/', '', $categoryBreadcrumb);
|
| 197 |
-
|
| 198 |
-
$responseField = $categoryBreadCrumbConfig[1];
|
| 199 |
-
$resultItem[$responseField] = $categoryBreadcrumb;
|
| 200 |
-
}
|
| 201 |
-
|
| 202 |
-
// MANUFACTURER NAME
|
| 203 |
-
$manufacturerNameRequested = $manufacturerNameConfig[0];
|
| 204 |
-
if($manufacturerNameRequested) {
|
| 205 |
-
|
| 206 |
-
$manufacturer = $productToRetreive->getResource()->getAttribute("manufacturer");
|
| 207 |
-
if (!empty($manufacturer)) {
|
| 208 |
-
|
| 209 |
-
$manufacturerName = $manufacturer->getFrontend()->getValue($productToRetreive);
|
| 210 |
-
$manufacturerNameNullValue = $manufacturerNameConfig[2];
|
| 211 |
-
if(empty($manufacturerName) || $manufacturerName == $manufacturerNameNullValue) {
|
| 212 |
-
$manufacturerName = '';
|
| 213 |
-
}
|
| 214 |
-
$responseField = $manufacturerNameConfig[1];
|
| 215 |
-
$resultItem[$responseField] = $manufacturerName;
|
| 216 |
-
}
|
| 217 |
-
}
|
| 218 |
-
|
| 219 |
-
// ABSOLUTE URL & IMAGE
|
| 220 |
-
$absoluteUrlRequested = $absoluteUrlConfig[0];
|
| 221 |
-
$absoluteImageUrlRequested = $absoluteImageUrlConfig[0];
|
| 222 |
-
if($absoluteUrlRequested || $absoluteImageUrlRequested) {
|
| 223 |
-
|
| 224 |
-
$productUrl = $productToRetreive->getUrlKey();
|
| 225 |
-
$productImage = $productToRetreive->getImage();
|
| 226 |
-
|
| 227 |
-
$noSelectionValue = $absoluteImageUrlConfig[2];
|
| 228 |
-
|
| 229 |
-
//If it's a simple product and it's NOT visible then we are getting the URL/ImageURL from the parent (configurable/grouped) product
|
| 230 |
-
if($productToRetreive->getTypeId() == 'simple' && $productToRetreive->getData("visibility") == 1)
|
| 231 |
-
{
|
| 232 |
-
//Checking if the product is a child of a "configurable" product
|
| 233 |
-
$parentProductIds = Mage::getModel(self::CONFIGURABLE_PRODUCT_MODEL)->getParentIdsByChild($productIdToRetreive);
|
| 234 |
-
|
| 235 |
-
//Checking if the product is a child of a "grouped" product
|
| 236 |
-
if(sizeof($parentProductIds) < 1) {
|
| 237 |
-
$parentProductIds = Mage::getModel(self::GROUPED_PRODUCT_MODEL)->getParentIdsByChild($productIdToRetreive);
|
| 238 |
-
}
|
| 239 |
-
|
| 240 |
-
//Setting the URL SEO to the parent URL if a parent is found
|
| 241 |
-
if(isset($parentProductIds[0]))
|
| 242 |
-
{
|
| 243 |
-
$firstParentProduct = Mage::getModel(self::CATALOG_PRODUCT_MODEL)->load($parentProductIds[0]);
|
| 244 |
-
$productUrl = $firstParentProduct->getUrlPath();
|
| 245 |
-
|
| 246 |
-
if($productImage == "" || $productImage == $noSelectionValue) {
|
| 247 |
-
$productImage = $firstParentProduct->getImage();
|
| 248 |
-
}
|
| 249 |
-
}
|
| 250 |
-
//Blanking-out the URL/Image URL since items that are not visible and are not associated with a parent
|
| 251 |
-
else
|
| 252 |
-
{
|
| 253 |
-
$productUrl = null;
|
| 254 |
-
$productImage = null;
|
| 255 |
-
}
|
| 256 |
-
}
|
| 257 |
-
|
| 258 |
-
if($absoluteUrlRequested && !empty($productUrl)) {
|
| 259 |
-
$responseField = $absoluteUrlConfig[1];
|
| 260 |
-
$resultItem[$responseField] = $baseUrl . $productUrl;
|
| 261 |
-
}
|
| 262 |
-
|
| 263 |
-
if($absoluteImageUrlRequested && !empty($productImage) && $productImage != $noSelectionValue) {
|
| 264 |
-
$responseField = $absoluteImageUrlConfig[1];
|
| 265 |
-
$resultItem[$responseField] = $imageBaseURL . $productImage;
|
| 266 |
-
}
|
| 267 |
-
}
|
| 268 |
|
|
|
|
|
|
|
| 269 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 270 |
|
| 271 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 272 |
}
|
| 273 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 274 |
}
|
|
|
|
|
|
|
| 275 |
}
|
| 276 |
}
|
| 277 |
|
| 278 |
return $resultItems;
|
| 279 |
}
|
| 280 |
|
| 281 |
-
private function getProductsFilteredByStockQuantity(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
$filteredProductsCollection =
|
| 284 |
Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
|
@@ -307,6 +317,38 @@ class GoDataFeed_Services_Model_Catalog_Product_Api extends Mage_Catalog_Model_P
|
|
| 307 |
}
|
| 308 |
}
|
| 309 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 310 |
return $filteredProductsCollection;
|
| 311 |
}
|
| 312 |
|
| 13 |
const DESCRIPTION_FIELD = 'description';
|
| 14 |
const SHORT_DESCRIPTION_FIELD = 'short_description';
|
| 15 |
const CATEGORY_NAME_FIELD = 'name';
|
| 16 |
+
const MANUFACTURER_FIELD = 'manufacturer';
|
| 17 |
+
const VISIBILITY_FIELD = 'visibility';
|
| 18 |
|
| 19 |
const CATEGORY_SEPARATOR = ' > ';
|
| 20 |
|
| 21 |
public function count($filters, $stockQuantityFilterAmount, $store, $responseField)
|
| 22 |
{
|
| 23 |
+
$filteredProductsCollection = $this->getProductsFilteredByStockQuantity(
|
| 24 |
+
$filters,
|
| 25 |
+
$stockQuantityFilterAmount,
|
| 26 |
+
$store,
|
| 27 |
+
array(),
|
| 28 |
+
array(),
|
| 29 |
+
false,
|
| 30 |
+
false,
|
| 31 |
+
false,
|
| 32 |
+
0,
|
| 33 |
+
0
|
| 34 |
+
);
|
| 35 |
|
| 36 |
$numberOfProducts = 0;
|
| 37 |
if(!empty($filteredProductsCollection)) {
|
| 70 |
$storeId = $this->_getStoreId($store);
|
| 71 |
|
| 72 |
// GET PRODUCTS FOR REQUESTED STORE WITH SPECIFIED FILTERS
|
| 73 |
+
$manufacturerNameRequested = $manufacturerNameConfig[0];
|
| 74 |
+
$absoluteUrlRequested = $absoluteUrlConfig[0];
|
| 75 |
+
$absoluteImageUrlRequested = $absoluteImageUrlConfig[0];
|
| 76 |
+
$filteredProductsCollection =
|
| 77 |
+
$this->getProductsFilteredByStockQuantity(
|
| 78 |
+
$filters,
|
| 79 |
+
$stockQuantityFilterAmount,
|
| 80 |
+
$store,
|
| 81 |
+
$attributes,
|
| 82 |
+
$customAttributes,
|
| 83 |
+
$manufacturerNameRequested,
|
| 84 |
+
$absoluteUrlRequested,
|
| 85 |
+
$absoluteImageUrlRequested,
|
| 86 |
+
$pageNumber,
|
| 87 |
+
$productsPerPage
|
| 88 |
+
);
|
| 89 |
|
| 90 |
if(!empty($filteredProductsCollection)) {
|
| 91 |
|
| 92 |
+
foreach ($filteredProductsCollection as $productToRetrieve) {
|
| 93 |
|
| 94 |
+
$resultItem = array();
|
|
|
|
|
|
|
| 95 |
|
| 96 |
+
// STANDARD ATTRIBUTES
|
| 97 |
+
if(!empty($attributes) && is_array($attributes)) {
|
| 98 |
+
foreach($attributes as $attribute)
|
| 99 |
+
{
|
| 100 |
+
$resultItem[$attribute] = $productToRetrieve->getData($attribute);
|
| 101 |
+
}
|
| 102 |
+
}
|
| 103 |
|
| 104 |
+
// CUSTOM ATTRIBUTES
|
| 105 |
+
if(!empty($customAttributes) && is_array($customAttributes)) {
|
| 106 |
+
foreach($customAttributes as $customAttribute)
|
| 107 |
+
{
|
| 108 |
+
$attributeField = $productToRetrieve->getResource()->getAttribute($customAttribute);
|
| 109 |
|
| 110 |
+
//If it's an option or multiselect attribute
|
| 111 |
+
if(!empty($attributeField) && $attributeField->usesSource() && $productToRetrieve->getAttributeText($customAttribute)) {
|
| 112 |
+
$attributeFieldValue = $productToRetrieve->getAttributeText($customAttribute);
|
| 113 |
+
}
|
| 114 |
+
else {
|
| 115 |
+
$attributeFieldValue = $productToRetrieve->getData($customAttribute);
|
| 116 |
+
}
|
| 117 |
|
| 118 |
+
if($scrubCustomAttribute) {
|
| 119 |
+
$attributeFieldValue = $this->scrubData($attributeFieldValue);
|
| 120 |
+
}
|
| 121 |
|
| 122 |
+
$resultItem[$customAttribute] = $attributeFieldValue;
|
| 123 |
+
}
|
| 124 |
+
}
|
| 125 |
|
| 126 |
+
// PRODUCT NAME SCRUBBING
|
| 127 |
+
if(in_array(self::PRODUCT_NAME_FIELD, $attributes) && $scrubProductName) {
|
| 128 |
+
$productName = $resultItem[self::PRODUCT_NAME_FIELD];
|
| 129 |
+
$resultItem[self::PRODUCT_NAME_FIELD] = $this->scrubData($productName);
|
| 130 |
+
}
|
| 131 |
|
| 132 |
+
// DESCRIPTION SCRUBBING
|
| 133 |
+
if(in_array(self::DESCRIPTION_FIELD, $attributes) && $scrubDescription) {
|
| 134 |
+
$resultItem[self::DESCRIPTION_FIELD] =
|
| 135 |
+
$this->scrubData($resultItem[self::DESCRIPTION_FIELD]);
|
| 136 |
+
}
|
| 137 |
|
| 138 |
+
// SHORT DESCRIPTION SCRUBBING
|
| 139 |
+
if(in_array(self::SHORT_DESCRIPTION_FIELD, $attributes) && $scrubShortDescription) {
|
| 140 |
+
$resultItem[self::SHORT_DESCRIPTION_FIELD] =
|
| 141 |
+
$this->scrubData($resultItem[self::SHORT_DESCRIPTION_FIELD]);
|
| 142 |
+
}
|
|
|
|
| 143 |
|
| 144 |
+
// IS IN STOCK & QUANTITY ATTRIBUTES
|
| 145 |
+
$stockQuantityRequested = $qtyConfig[0];
|
| 146 |
+
$stockStatusRequested = $isInStockConfig[0];
|
| 147 |
+
if($stockQuantityRequested || $stockStatusRequested) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 148 |
|
| 149 |
+
$inventoryStatus = Mage::getModel(self::STOCK_ITEM_MODEL)->loadByProduct($productToRetrieve);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
+
if (!empty($inventoryStatus)) {
|
|
|
|
|
|
|
|
|
|
|
|
|
| 152 |
|
| 153 |
+
if($stockQuantityRequested) {
|
| 154 |
+
$responseField = $qtyConfig[1];
|
| 155 |
+
$resultItem[$responseField] = $inventoryStatus->getQty();
|
| 156 |
+
}
|
|
|
|
| 157 |
|
| 158 |
+
if($stockStatusRequested) {
|
| 159 |
+
$responseField = $isInStockConfig[1];
|
| 160 |
+
$resultItem[$responseField] = $inventoryStatus->getIsInStock();
|
| 161 |
+
}
|
| 162 |
+
}
|
| 163 |
+
}
|
| 164 |
|
| 165 |
+
// ATTRIBUTE SET NAME
|
| 166 |
+
$attributeSetNameRequested = $attributeSetNameConfig[0];
|
| 167 |
+
if($attributeSetNameRequested) {
|
| 168 |
|
| 169 |
+
$attributeSet = Mage::getModel(self::ATTRIBUTE_SET_MODEL)->load($productToRetrieve->getAttributeSetId());
|
| 170 |
+
if (!empty($attributeSet)) {
|
| 171 |
|
| 172 |
+
$attributeSetName = $attributeSet->getAttributeSetName();
|
| 173 |
+
if($scrubAttributeSetName) {
|
| 174 |
+
$attributeSetName = $this->scrubData($attributeSetName);
|
| 175 |
+
}
|
| 176 |
|
| 177 |
+
$responseField = $attributeSetNameConfig[1];
|
| 178 |
+
$resultItem[$responseField] = $attributeSetName;
|
| 179 |
+
}
|
| 180 |
+
}
|
|
|
|
|
|
|
| 181 |
|
| 182 |
+
// CATEGORY BREADCRUMB
|
| 183 |
+
$categoryBreadCrumbRequested = $categoryBreadCrumbConfig[0];
|
| 184 |
+
if($categoryBreadCrumbRequested) {
|
| 185 |
|
| 186 |
+
$categoryIds = $productToRetrieve->getCategoryIds();
|
|
|
|
| 187 |
|
| 188 |
+
if (!empty($categoryIds)) {
|
|
|
|
|
|
|
|
|
|
| 189 |
|
| 190 |
+
$categoryBreadcrumb = '';
|
| 191 |
+
foreach($categoryIds as $categoryId) {
|
|
|
|
|
|
|
| 192 |
|
| 193 |
+
$category = Mage::getModel(self::CATALOG_CATEGORY_MODEL)->setStoreId($storeId)->load($categoryId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 194 |
|
| 195 |
+
if(!empty($category) && $category->getId()) {
|
| 196 |
+
$categoryBreadcrumb .= $category->getData(self::CATEGORY_NAME_FIELD) . self::CATEGORY_SEPARATOR;
|
| 197 |
}
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
$categoryBreadcrumb = preg_replace('/' . self::CATEGORY_SEPARATOR . '$/', '', $categoryBreadcrumb);
|
| 201 |
+
|
| 202 |
+
$responseField = $categoryBreadCrumbConfig[1];
|
| 203 |
+
$resultItem[$responseField] = $categoryBreadcrumb;
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
// MANUFACTURER NAME
|
| 208 |
+
if($manufacturerNameRequested) {
|
| 209 |
+
|
| 210 |
+
$manufacturer = $productToRetrieve->getResource()->getAttribute(self::MANUFACTURER_FIELD);
|
| 211 |
+
if (!empty($manufacturer)) {
|
| 212 |
+
|
| 213 |
+
$manufacturerName = $manufacturer->getFrontend()->getValue($productToRetrieve);
|
| 214 |
+
$manufacturerNameNullValue = $manufacturerNameConfig[2];
|
| 215 |
+
if(empty($manufacturerName) || $manufacturerName == $manufacturerNameNullValue) {
|
| 216 |
+
$manufacturerName = '';
|
| 217 |
+
}
|
| 218 |
+
$responseField = $manufacturerNameConfig[1];
|
| 219 |
+
$resultItem[$responseField] = $manufacturerName;
|
| 220 |
+
}
|
| 221 |
+
}
|
| 222 |
|
| 223 |
+
// ABSOLUTE URL & IMAGE
|
| 224 |
+
if($absoluteUrlRequested || $absoluteImageUrlRequested) {
|
| 225 |
+
|
| 226 |
+
$productUrl = $productToRetrieve->getUrlPath();
|
| 227 |
+
$productImage = $productToRetrieve->getImage();
|
| 228 |
+
|
| 229 |
+
$noSelectionValue = $absoluteImageUrlConfig[2];
|
| 230 |
+
|
| 231 |
+
//If it's a simple product and it's NOT visible then we are getting the URL/ImageURL from the parent (configurable/grouped) product
|
| 232 |
+
if($productToRetrieve->getTypeId() == 'simple' && $productToRetrieve->getData(self::VISIBILITY_FIELD) == 1)
|
| 233 |
+
{
|
| 234 |
+
$productIdToRetrieve = $productToRetrieve->getId();
|
| 235 |
+
|
| 236 |
+
//Checking if the product is a child of a "configurable" product
|
| 237 |
+
$parentProductIds = Mage::getModel(self::CONFIGURABLE_PRODUCT_MODEL)->getParentIdsByChild($productIdToRetrieve);
|
| 238 |
+
|
| 239 |
+
//Checking if the product is a child of a "grouped" product
|
| 240 |
+
if(sizeof($parentProductIds) < 1) {
|
| 241 |
+
$parentProductIds = Mage::getModel(self::GROUPED_PRODUCT_MODEL)->getParentIdsByChild($productIdToRetrieve);
|
| 242 |
+
}
|
| 243 |
+
|
| 244 |
+
//Setting the URL SEO to the parent URL if a parent is found
|
| 245 |
+
if(isset($parentProductIds[0]))
|
| 246 |
+
{
|
| 247 |
+
$firstParentProduct = Mage::getModel(self::CATALOG_PRODUCT_MODEL)->load($parentProductIds[0]);
|
| 248 |
+
$productUrl = $firstParentProduct->getUrlPath();
|
| 249 |
+
|
| 250 |
+
if($productImage == "" || $productImage == $noSelectionValue) {
|
| 251 |
+
$productImage = $firstParentProduct->getImage();
|
| 252 |
+
}
|
| 253 |
+
}
|
| 254 |
+
//Blanking-out the URL/Image URL since items that are not visible and are not associated with a parent
|
| 255 |
+
else
|
| 256 |
+
{
|
| 257 |
+
$productUrl = null;
|
| 258 |
+
$productImage = null;
|
| 259 |
}
|
| 260 |
}
|
| 261 |
+
|
| 262 |
+
if($absoluteUrlRequested && !empty($productUrl)) {
|
| 263 |
+
$responseField = $absoluteUrlConfig[1];
|
| 264 |
+
$resultItem[$responseField] = $baseUrl . $productUrl;
|
| 265 |
+
}
|
| 266 |
+
|
| 267 |
+
if($absoluteImageUrlRequested && !empty($productImage) && $productImage != $noSelectionValue) {
|
| 268 |
+
$responseField = $absoluteImageUrlConfig[1];
|
| 269 |
+
$resultItem[$responseField] = $imageBaseURL . $productImage;
|
| 270 |
+
}
|
| 271 |
}
|
| 272 |
+
|
| 273 |
+
$resultItems[] = $resultItem;
|
| 274 |
}
|
| 275 |
}
|
| 276 |
|
| 277 |
return $resultItems;
|
| 278 |
}
|
| 279 |
|
| 280 |
+
private function getProductsFilteredByStockQuantity(
|
| 281 |
+
$filters,
|
| 282 |
+
$stockQuantityFilterAmount,
|
| 283 |
+
$store,
|
| 284 |
+
$attributes,
|
| 285 |
+
$customAttributes,
|
| 286 |
+
$manufacturerNameRequested,
|
| 287 |
+
$absoluteUrlRequested,
|
| 288 |
+
$absoluteImageUrlRequested,
|
| 289 |
+
$pageNumber,
|
| 290 |
+
$productsPerPage
|
| 291 |
+
) {
|
| 292 |
|
| 293 |
$filteredProductsCollection =
|
| 294 |
Mage::getModel(self::CATALOG_PRODUCT_MODEL)
|
| 317 |
}
|
| 318 |
}
|
| 319 |
|
| 320 |
+
if($pageNumber != 0) {
|
| 321 |
+
$filteredProductsCollection->setPage($pageNumber, $productsPerPage);
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
if (is_array($attributes)) {
|
| 325 |
+
foreach ($attributes as $attribute) {
|
| 326 |
+
$filteredProductsCollection->addAttributeToSelect($attribute);
|
| 327 |
+
}
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
if (is_array($customAttributes)) {
|
| 331 |
+
foreach ($customAttributes as $attribute) {
|
| 332 |
+
$filteredProductsCollection->addAttributeToSelect($attribute);
|
| 333 |
+
}
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
if($manufacturerNameRequested) {
|
| 337 |
+
$filteredProductsCollection->addAttributeToSelect(self::MANUFACTURER_FIELD);
|
| 338 |
+
}
|
| 339 |
+
|
| 340 |
+
if($absoluteUrlRequested) {
|
| 341 |
+
$filteredProductsCollection->addAttributeToSelect('url_path');
|
| 342 |
+
}
|
| 343 |
+
|
| 344 |
+
if($absoluteImageUrlRequested) {
|
| 345 |
+
$filteredProductsCollection->addAttributeToSelect('image');
|
| 346 |
+
}
|
| 347 |
+
|
| 348 |
+
if($absoluteUrlRequested || $absoluteImageUrlRequested) {
|
| 349 |
+
$filteredProductsCollection->addAttributeToSelect(self::VISIBILITY_FIELD);
|
| 350 |
+
}
|
| 351 |
+
|
| 352 |
return $filteredProductsCollection;
|
| 353 |
}
|
| 354 |
|
package.xml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>GoDataFeed</name>
|
| 4 |
-
<version>1.0.
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.godatafeed.com/aboutus.aspx">©GoDataFeed All rights reserved</license>
|
| 7 |
<channel>community</channel>
|
|
@@ -9,10 +9,10 @@
|
|
| 9 |
<summary>A simple and affordable way to optimize your product listings, automate your datafeed submissions and drive more qualified, targeted traffic to your Website.</summary>
|
| 10 |
<description>This extension optimizes product retrieval while providing enhanced attributes information. Install this extension to fully benefit GoDataFeed services.</description>
|
| 11 |
<notes>No Notes</notes>
|
| 12 |
-
<authors><author><name>GoDataFeedSupport</name><user>
|
| 13 |
-
<date>2012-02-
|
| 14 |
-
<time>
|
| 15 |
-
<contents><target name="magelocal"><dir name="GoDataFeed"><dir name="Services"><dir name="Model"><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="
|
| 16 |
<compatible/>
|
| 17 |
-
<dependencies
|
| 18 |
</package>
|
| 1 |
<?xml version="1.0"?>
|
| 2 |
<package>
|
| 3 |
<name>GoDataFeed</name>
|
| 4 |
+
<version>1.0.1</version>
|
| 5 |
<stability>stable</stability>
|
| 6 |
<license uri="http://www.godatafeed.com/aboutus.aspx">©GoDataFeed All rights reserved</license>
|
| 7 |
<channel>community</channel>
|
| 9 |
<summary>A simple and affordable way to optimize your product listings, automate your datafeed submissions and drive more qualified, targeted traffic to your Website.</summary>
|
| 10 |
<description>This extension optimizes product retrieval while providing enhanced attributes information. Install this extension to fully benefit GoDataFeed services.</description>
|
| 11 |
<notes>No Notes</notes>
|
| 12 |
+
<authors><author><name>GoDataFeedSupport</name><user>GoDataFeedSupport</user><email>support@godatafeed.com</email></author></authors>
|
| 13 |
+
<date>2012-02-06</date>
|
| 14 |
+
<time>19:47:22</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="GoDataFeed"><dir name="Services"><dir name="Model"><dir name="Catalog"><dir name="Product"><file name="Api.php" hash="75b40084552c9b8cdf65708fe6ce9296"/></dir></dir></dir><dir name="etc"><file name="api.xml" hash="565bc8cb3899d89f37c0cc27008958f4"/><file name="config.xml" hash="8ecde4bbb6d08c822c1173f279d21bca"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GoDataFeed_Services.xml" hash="43db0e2dd6a412462d52e77143ec5cdc"/></dir></target></contents>
|
| 16 |
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
</package>
|
