Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Merge pull request #193 from DivanteLtd/bugfix/magento-install
Browse files Browse the repository at this point in the history
Fixes for clean magento install with sample data modules.
  • Loading branch information
afirlejczyk authored Jan 23, 2020
2 parents 2ca85f1 + 26b94e1 commit ebfa60b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Sign up for a demo at https://vuestorefront.io/ (Vue Storefront integrated with
## Overview

### Version 1.5.0/1.5.1 - support for aliases.
Command ` php bin/magento vsbridge:reindex` will reindex all data to new index.
Command ` php bin/magento vsbridge:reindex --all` will reindex all data to new index.
It will create new index and update aliases at the end.

If you used previous versions, you will have to delete index (created with this extension) from ES manually:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function prepareConfigurableProduct(array $productDTO)
$hasPrice = $this->hasPrice($productDTO);

foreach ($configurableChildren as $child) {
if ($child['stock']['is_in_stock']) {
if (!empty($child['stock']['is_in_stock'])) {
$areChildInStock = 1;
}

Expand All @@ -268,9 +268,7 @@ private function prepareConfigurableProduct(array $productDTO)
}
}

$isInStock = $productDTO['stock']['is_in_stock'];

if (!$isInStock || !$areChildInStock) {
if (!empty($productDTO['stock']['is_in_stock']) || !$areChildInStock) {
$productDTO['stock']['is_in_stock'] = false;
$productDTO['stock']['stock_status'] = 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function getAttributesById()
*/
public function getAttributeById($attributeId)
{
return $this->loadAttributes->getAttributeById($attributeId);
return $this->loadAttributes->getAttributeById((int) $attributeId);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,7 @@ private function getConfigurableAttributesForProductsFromResource(array $product
->where('product_id IN (?)', $productIds);
$this->dbHelper->addGroupConcatColumn($select, 'attribute_ids', 'attribute_id');

$attributes = $this->getConnection()->fetchAssoc($select);

return $attributes;
return $this->getConnection()->fetchAssoc($select);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,7 @@ private function initAttributes()
$attributeCollection = $this->getAttributeCollection();

foreach ($attributeCollection as $attribute) {
$this->prepareAttribute($attribute);

$this->attributesById[$attribute->getId()] = $attribute;
$this->attributeCodeToId[$attribute->getAttributeCode()] = $attribute->getId();
$this->addAttribute($attribute);
}
}

Expand All @@ -88,7 +85,7 @@ private function initAttributes()
* @return Attribute
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAttributeById($attributeId)
public function getAttributeById(int $attributeId)
{
$this->initAttributes();

Expand All @@ -105,9 +102,10 @@ public function getAttributeById($attributeId)
* @return Attribute
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getAttributeByCode($attributeCode)
public function getAttributeByCode(string $attributeCode)
{
$this->initAttributes();
$this->loadAttributeByCode($attributeCode);

if (isset($this->attributeCodeToId[$attributeCode])) {
$attributeId = $this->attributeCodeToId[$attributeCode];
Expand All @@ -118,6 +116,34 @@ public function getAttributeByCode($attributeCode)
throw new \Magento\Framework\Exception\LocalizedException(__('Attribute not found.'));
}

/**
* @param string $attributeCode
*/
private function loadAttributeByCode(string $attributeCode)
{
if (!isset($this->attributeCodeToId[$attributeCode])) {
$attributeCollection = $this->getAttributeCollection();
$attributeCollection->addFieldToFilter('attribute_code', $attributeCode);
$attributeCollection->setPageSize(1)->setCurPage(1);

$attribute = $attributeCollection->getFirstItem();

if ($attribute->getId()) {
$this->addAttribute($attribute);
}
}
}

/**
* @param Attribute $attribute
*/
private function addAttribute(Attribute $attribute)
{
$this->prepareAttribute($attribute);
$this->attributesById[$attribute->getId()] = $attribute;
$this->attributeCodeToId[$attribute->getAttributeCode()] = $attribute->getId();
}

/**
* @param Attribute $attribute
*
Expand Down

0 comments on commit ebfa60b

Please sign in to comment.